Silly Question On WindowProc

Started by
4 comments, last by Endurion 18 years, 3 months ago
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.
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?
Scratch that :), didn't notice you were talking about MFC. Post some code so we can see what you're on about.
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. ;)
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
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.
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement