Sign in to follow this  
funvill

PostMessage(WM_COMMAND, MY_COMMAND)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this