Jump to content
  • Advertisement


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


Message handling & multiple inheritance

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

If you intended to correct an error in the post then please contact us.

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?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!