By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Intercepting windows messages

yuumei
P: 5
Hi, this is my first post on a usergroup, please go easy on me :3

Im trying to intercept some input messages from a windows message loop:
Expand|Select|Wrap|Line Numbers
  1. //while (GetMessage(&wmsg, NULL, 0, 0))
  2. //while (PeekMessage(&wmsg, NULL, 0, 0, PM_REMOVE))
  3. {
  4. CallWindowProc(W32HandleWindowsMessage, hwnd, wmsg.message, wmsg.wParam, wmsg.lParam);
  5. }
  6.  
The GetMessage version seems to break when I get a WM_INPUT message, but then hangs and never gets out of the loop.
The PeekMessage dosent seems to break, so im assuming its not getting the WE_INPUT message.

Am I doing it right? Any pointers?

Thankyouuuu
Jun 10 '07 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
You need to look up the documentation on GetMessage and PeekMessage (Google is your friend in this).

GetMessage returns true unless the message it is processing is a WM_QUIT message otherwise it returns false. It should probably only be used in your programs main message loop (although there are times when setting up an alternate message loop is done).

PeekMessage only returns true if there was a message waiting in the message queue that it retrieved and returned, otherwise it returns false. since it is likely that most of the time there is not a message waiting it is like that your whole loop is never entered. PeekMessage is not really designed to be used as the control for a while loop but more in an if inside a loop of some sort to allow processing of messages to continue while the loop executes.
Jun 10 '07 #2

yuumei
P: 5
Thanks for the advice, I found out that I was already getting the message before that part of the code x_x
So I was getting an empty queue
Jun 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.