hi,
don't know why. but can't get the ctrl , shift keypresses to work in the WM_LBUTTONDOWN msg, I have similar code for the WM_LBUTTONUP msg & it all works proper there
this code doesn't work
.elseif uMsg == WM_LBUTTONDOWN
movzx ecx, word ptr [lParam] ; x coordinate
movzx edx, word ptr [lParam+2] ; y coordiate
; fn MessageBox, 0, ustr$(ecx), "x coordinate", MB_OK
.if wParam == MK_SHIFT
fn MessageBox, 0, "shift key down", "Keys", MB_OK
.endif
xor eax, eax
ret
this worksas expected. . .
.elseif uMsg == WM_LBUTTONUP
mov ecx, MK_CONTROL
or ecx, MK_SHIFT
.if wParam == ecx
fn MessageBox, 0, "shift and ctrl pressed", "K e y s", MB_OK
.endif
xor eax, eax
ret
wParam is a bitmask, so more than one bit could be set.
mov eax,wParam
and eax,MK_SHIFT or MK_CONTROL
cmp eax,MK_SHIFT
jz shift_pressed
cmp eax,MK_CONTROL
jz control_pressed
cmp eax,MK_SHIFT or MK_CONTROL
jz both_pressed
thanks.
just realised its because MK_LBUTTON is also set in the case of the buttondown msg, but is not set in the buttonup msg, that's why it works in the buttonup only. I modified my code for WM_LBUTTONDOWN to this, & it works right now.
.elseif uMsg == WM_LBUTTONDOWN
.if wParam == MK_SHIFT or MK_LBUTTON
fn MessageBox, 0, "shift key down", "Keys", MB_OK
.endif
xor eax, eax
ret
-
Don't forget that there could be others -
MK_CONTROL,MK_LBUTTON,MK_MBUTTON,MK_RBUTTON,MK_SHIFT,MK_XBUTTON1,MK_XBUTTON2
You're better off using TEST (or even BT) to 'isolate' the separate bits in wParam.