Jump to content
  • Advertisement
Sign in to follow this  
funvill

PostMessage(WM_COMMAND, MY_COMMAND)

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

Hello I just wondering if this would be "acceptable" or if there is a better way of doing it. I want to make my game more event driven then state based, and i was wondering if i can add custom message to the windows message cue i was thinking of doing it this way i would post a message using ( PostMessage(WM_COMMAND, MY_COMMAND) ) and process it in the main message function. MY_COMMAND being one of my own types The reason that I want to process the messages in the main message function is that I also am interested in the other commands like WM_PAINT and so on. Is this "acceptable" way of doing things or should I make my own message que for my messages?? PS. if I asked this question in a Bad Way, tell me so I know for next time.

Share this post


Link to post
Share on other sites
Advertisement
You can do this, but there's an even better method. Windows actually has a specific set of codes that you can use for custom messages. Any message ID that is greater than WM_APP can be used for custom messages. This is a very good way to make your program more event-centered without having to write your own event system or anything messy like that.

There's some details about WM_APP on MSDN that should get you started.

Share this post


Link to post
Share on other sites
However, most WM_COMMAND messages are application defined anyway (e.g control IDs, Menu IDs)

In any case. There is no reason why not, i used the methord loads.

One tip, if in the future you use multi-threading, dont get caught like me, each thread has its own message queue.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!