> > var
> > KS:Tkeyboardstate;
> > begin
> > KS[VK_NUMLOCK]:= VK_NUMLOCK AND (NOT 1);
> > SetKeyboardState(KS);
> > end;
>
> That piece above doesn't toggle the state does it? Since the RHS
> of the assignment
> doesn't refer to the current state at all.
>
> That is: Should the toggle line be
> KS[VK_NUMLOCK] := KS[VK_NUMLOCK] XOR -1;
Yep ur rite. It just toggles an on NumLock to off. What u have there is
betta.
Here is the full code fom a quote:
VAR
KS : TKeyboardState;
...
GetKeyboardState(KS);
IF Odd(KS[VK_NUMLOCK]) THEN {NumLock is ON}
KS[VK_NUMLOCK] := KS[VK_NUMLOCK] XOR 1; {toggle numlock}
KS[VK_NUMLOCK] := KS[VK_NUMLOCK] OR 1; {numlock ON}
KS[VK_NUMLOCK] := KS[VK_NUMLOCK] AND (NOT 1); {numlock OFF}
SetKeyboardState(KS);
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz