• Advertisement
Sign in to follow this  

Silly Question On WindowProc

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

I have a silly question regarding WindowProc. I tried to use ON_WM_LBUTTONDOWN message map to perform an action. However, the action never happened when I clicked the mouse. I assumed my class never got the message and someone else processed it. However, I used GetAsyncKeyState(VK_LBUTTON) inside the WindowProc member func and it seemed to work. I thought WindowProc only got called when a message arrived. This kills my first theory. I think WindowProc is also getting the mouse move message. Any ideas on what's going on? Thanks for the help.

Share this post


Link to post
Share on other sites
Advertisement
The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.

I got this from a win32 reference. So i guess your problem is that it should be WM_LBUTTONDOWN instead of ON_WM_LBUTTONDOWN, am i right?

Share this post


Link to post
Share on other sites
Scratch that :), didn't notice you were talking about MFC. Post some code so we can see what you're on about.

Share this post


Link to post
Share on other sites
Is the mouse over your window when you click the button? If so then your window should receive the WM_LBUTTONDOWN message. You can always check this with Spy++ if you're not sure. If Spy++ shows the message being received then there is something wrong in your code.

By using GetAsyncKeyState you can get the status of keys and mouse buttons at any time, but this would require you to constantly poll the mouse to see what it's doing. Better to rely on the message mechanism. ;)

Share this post


Link to post
Share on other sites
Thanks for the help. I was thinking about looking up the message codes that WindowProc is processing. I can't seem to find the a list. The help does not have a link. MSDN must have one somewhere. I placed a trace inside and get message 32 and 867. These numbers mean nothing without a table to look up. Thanks again.

Share this post


Link to post
Share on other sites
I reckon your numbers are dezimal. The defines are in winuser.h.

32 is WM_SETCURSOR, 867 seems to be a MFC custom message.

Actually if you only get two messages something's very wrong.

Share this post


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

  • Advertisement