Author: Kevin Howell
How do I check for a Numlock enabled and Capslock enable?
Answer:
Here are two procedures that you add to the main form of your application:
1 procedure TfrmMain.CheckCapslock;
2 begin3 if Odd(Getkeystate(VK_CAPITAL)) then4 Statusline.Panels[1].text := 'CAPS'
5 else6 Statusline.Panels[1].text := '';
7 end;
8 9 procedure TfrmMain.CheckNumlock;
10 begin11 if Odd(Getkeystate(VK_NUMLOCK)) then12 Statusline.Panels[2].text := 'NUM'
13 else14 Statusline.Panels[2].text := '';
15 end;
16 17 Add a application component to your project and simply call both these procedures
18 in the Application.onmessage event i.e.:
19 20 procedure TfrmMain.ApplicationEvents1Message(var Msg: tagMSG;
21 var Handled: Boolean);
22 begin23 CheckCapslock;
24 CheckNumlock;
25 end;