Skip to main content
gamedev.net
🔒 Locked

PostMessage(WM_COMMAND, MY_COMMAND)

Started by funvill 2 replies 2.4k views
Original Post
funvill
funvill
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.
ApochPiQ
ApochPiQ
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.
Empirical
Empirical
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.

Topic Locked

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

Sign in to reply to this topic.