Jump to content
  • Advertisement


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


Msg Handler Wrapping...

This topic is 6029 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

Hi all, just wanted to know how you guys wrap up the Message Handler, which methods do you guys use... I use a method in which the user defines the window, and then defines if he wants his code to handle stuff like WM_CREATE, WM_DESTROY, keyboard, mouse events, or if he wants the code to handle it automaticly... and you?

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post

Link to post
Share on other sites
Mine sounds far less elegant, but gets the job done pretty well.

I usually encapsulate a window in a class, and then stuff the class pointer into either a Window Property, or into the GWLP_USERDATA slot (see GetWindowLongPtr if you don''t know what I''m talking about). Then I define a WindowProc method in the class that gets called. Each base class has it''s WindowProc implementation.. so each class builds on the previous one. The base class just calls DefWindowProc(). Then, depending on the class (and my mood =)), I either handle each message directly (in the switch/case block), or else have helper methods, like _OnCommand(), or more specific helpers like _OnFileExit(), etc.

I''ve used that method for a while now and it works pretty good. This is usually for normal Win32 apps though (not using DirectX), so I can''t say if it works real well for games (though I don''t see why it wouldn''t).


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!