TKeyboardState is an array[0..255] of byte, so there are 8 bits in each
entry.
>From the help for GetKeyboardState:
When the function returns, each member of the array pointed to by the
lpKeyState parameter contains status data for a virtual key. If the
high-order bit is 1, the key is down; otherwise, it is up. If the low-order
bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled
if it is turned on. The key is off and untoggled if the low-order bit is 0.
A toggle key's indicator light (if any) on the keyboard will be on when the
key is toggled, and off when the key is untoggled. 

So the point is to try to turn the low order bit on :
  KS[VK_NUMLOCK] := KS[VK_NUMLOCK] or 1; { Sets low order bit, doesnt touch
others. }
or off:
  KS[VK_NUMLOCK] := KS[VK_NUMLOCK] and not 1; { Clears low order bit, doesnt
touch others. }

Regards,
  Andrew Cooke.

> -----Original Message-----
> From: Aaron Scott-Boddendijk [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, July 27, 1999 3:12 PM
> To:   Multiple recipients of list delphi
> Subject:      Re: [DUG]:  NUM Lock ON-OFF
        [snip] 

> Also what are the valid values for the contents of each entry in that
> TKeyboardState
> Array? Are the values just True and False (0 and not 0) or do they have
> meaningful values.
> 
> Why is (NOT 1) used? Isn't that just -2 (2s complement is Negate and add 1
> isn't it and
> NOT is a binary not rather than arithmetic)
> 
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to