I'm just curious why I can't seem to handle the WM_COMMAND message in my subclassed button's wndproc. WM_LBUTTONUP/DOWN trigger fine, but nothing happens when I try to use WM_COMMAND. There's no WM_COMMAND handling in my main wndproc so there's no conflict there.

Has anyone else had problems processing the WM_COMMAND messages in a subclassed button?

Btw, there's nothing special in the way I'm subclassing (i.e. SetWindowLong) the button so I didn't feel like I needed to show an example here. If it's needed to troubleshoot my problem, feel free to ask and I'll copy/paste it. :)
Posted on 2002-07-22 11:49:53 by Will
Posted on 2002-07-22 12:14:52 by bazik
Thanks bAZiK. I suppose I can just use WM_LBUTTONUP, but I'll have to code a routine to ensure that the cursor is still over the button. That's annoying, but I'll live.

Thanks a bunch.
Posted on 2002-07-22 13:52:51 by Will
Chances are the button won't reieve the LBUTTONUP message if the cursor has move outside it anyway so there'd be no problem.
Posted on 2002-07-22 14:18:46 by Eóin
Actually if you press down and drag the mouse off the control and then release the left mouse button the control with the focus (the button) still receives the message.
Posted on 2002-07-22 17:07:12 by Will
I think the button will capture the mouse on WM_LBUTTONDOWN.
I found a good way of handling this is:



@@LButtonUp:
movzx eax,[lParam]
cmp eax,BUTTONWIDTH
ja @@NotInButton
movzx eax,[lParam+2]
cmp eax,BUTTONHEIGHT
ja @@NotInButton
@@InButton:
...
ret
@@NotInButton:
ret
Posted on 2002-07-23 14:54:07 by chorus
Thanks a bunch. Now I can be lazy and use your routine! :)
Posted on 2002-07-24 11:25:44 by Will