2010. május 16., vasárnap
Checking for Numlock and Capslock and displaying on Statusbar
Problem/Question/Abstract:
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:
procedure TfrmMain.CheckCapslock;
begin
if Odd(Getkeystate(VK_CAPITAL)) then
Statusline.Panels[1].text := 'CAPS'
else
Statusline.Panels[1].text := '';
end;
procedure TfrmMain.CheckNumlock;
begin
if Odd(Getkeystate(VK_NUMLOCK)) then
Statusline.Panels[2].text := 'NUM'
else
Statusline.Panels[2].text := '';
end;
Add a application component to your project and simply call both these procedures in the Application.onmessage event i.e.:
procedure TfrmMain.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
CheckCapslock;
CheckNumlock;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése