Re: GetAsyncKeyState(VK_LBUTTON) true after DoModal()
"Simon" <bad@example.com> wrote in message
news:#4ARD0Y1KHA.4724@TK2MSFTNGP02.phx.gbl...
Because if I click on the OK button the dialog box only closes when I
release the left button, so why would (GetAsyncKeyState(VK_LBUTTON)&
0x8000) == 0x8000 ) return true.
VK_LBUTTON is always the physical left mouse button, so if you have swapped
mouse buttons, you need to check VK_RBUTTON instead:
http://msdn.microsoft.com/en-us/library/ms646293%28VS.85%29.aspx
Also, it should be OK the way you have it, but just do:
if ( GetAsyncKeyState(VK_LBUTTON & 0x8000) ) // don't compare ==
0x8000
;
If this still does not work, what if you close the dialog by setting focus
to the OK button and use the keyboard? Does it then work? There might be
something going on with the dialog's DoModal() as that is a separate message
loop running, which might screw up the cached keyboard state (although I
understand GetAsyncKeyState doesn't use a cached state, it is supposed to be
what the hardware state is at the moment you call it.)
-- David