#### Archived

This topic is now archived and is closed to further replies.

# Message handling & multiple inheritance

This topic is 5650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Suppose I have this "application" class, which just sets up and registers a window. It has its own WndProc member function, which handles some messages or calls DefWndProc. Now, I derive a class from that which for instance sets up D3D and handles ALT+TABS, lost devices, that sort of thing. I also derive some other classes which set up DirectInput or DirectSound, for instance. All these derived classes also have their own WndProc members. Now, finally, to make the diamond complete, I have a final class which, through multiple inheritance, inherits both the D3D and the DI class. The first ''application'' class is a virtual base class, so you''d only have one shared base class at the top, the D3D and DI class in the middle, and the final class which inherited both the D3D and DI class at the bottom of the diamond. This final class also has a WndProc member. Something like this:


Base "application" class
/                    \
D3D Class                 DI Class
\                    /
Final custom DI & D3D Class

Is there any way to make the WndProc functions in such a way that a message first goes through the final class''s WndProc, then through the D3D Class''s WndProc, then the DI class''s WndProc, then the base class''s WndProc, and then calls DefWndProc when no WndProc has handled the message? I''ve been racking my brain on this for a few days, but just cant seem to come up with something solid. I guess I should''ve listened when people said multiple inheritance is hard... Any ideas?

• 10
• 16
• 14
• 18
• 15