Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to understand GetKeyState()... 1

Status
Not open for further replies.

thatguy

Programmer
Aug 1, 2001
283
0
0
US
Hey there folks--

I'm trying to use GetKeyState in a command button's click event to detect if the user did a Shift-Click or just a regular click.. I'm testing with this code in a click event
Code:
#DEFINE k_SHIFT 0x10

DECLARE INTEGER GetKeyState IN WIN32API INTEGER

?getkeystate(k_SHIFT)

I'm getting this following output:
[tt]
click 0
shift-click 65409
shift-click -127
shift-click -127
click 1
click 1
shift-click 65408
shift-click -128
shift-click -128
click 0
[/tt]

is this normal? do i need to test for (GetKeyState() < 0 or GetKeyState() > 1)?

thanks
-- frank~
 
Frank,

The MouseDown event provides that information natively as parameters.

pamela
 
duhh.. i'm an idiot.. i'll admit it..

still odd returns from getkeystate() tho, no?

thanks
-- frank~
 
The MSDN help indicates that GetKeyState may not return what is intuitive: The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top