Skip to main content
gamedev.net
🔒 Locked

Message handling & multiple inheritance

Started by CountOfMonteChristo Nov 30, 2002 at 8:02 PM 0 replies 450+ views
Original Post
CountOfMonteChristo
CountOfMonteChristo
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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.