Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Insert and NumLock key when form shows

rajsharajsha Member Posts: 75
How can i detect the state of the insert key and NumLock key when a form shows. I would then like to toggle the text INS and NUM in the status bar panels.
Thanx

Comments

  • jamesb800jamesb800 Member Posts: 105
    [b][red]This message was edited by jamesb800 at 2005-7-11 17:41:4[/red][/b][hr]
    Here is what I use to detect if numlock is on...

    [code]
    keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0), 0, 0);
    [/code]

    this is what I use to turn it on...

    [code]
    keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0)KEYEVENTF_KEYUP,0);
    [/code]

    I found this using a Google search for....VK_NUMLOCK, Delphi

    Could be something better, but it works for me.

    James


    : How can i detect the state of the insert key and NumLock key when a form shows. I would then like to toggle the text INS and NUM in the status bar panels.
    : Thanx
    :
    :



  • rajsharajsha Member Posts: 75
    Thanks, but I found this more useful
    [Code]
    procedure TForm1.FormShow(Sender: TObject);
    var
    NumLockState : boolean;
    InsLockState : boolean;
    CapsLockState : boolean;
    keys : TKeyboardState;
    begin
    GetKeyboardState(keys);
    //NumLock handling:
    NumLockState := ( keys[VK_NUMLOCK] > 0);
    If NumLockState <> True then
    StatusBar1.Panels[2].Text := '' else StatusBar1.Panels[2].Text := 'NUM';
    //CapsLock handling:
    CapsLockState := (keys[VK_CAPITAL] > 0);
    If CapsLockState <> True Then
    StatusBar1.Panels[3].Text:= '' else StatusBar1.Panels[3].Text := 'CAPS';
    // Insert Handling :
    StatusBar1.Panels[1].Text := 'INS' ;
    end;
    [/Code]
    Hope this code will be useful to anyone who needs it.
    Thanks again

    : [b][red]This message was edited by jamesb800 at 2005-7-11 17:41:4[/red][/b][hr]
    : Here is what I use to detect if numlock is on...
    :
    : [code]
    : keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0), 0, 0);
    : [/code]
    :
    : this is what I use to turn it on...
    :
    : [code]
    : keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0)KEYEVENTF_KEYUP,0);
    : [/code]
    :
    : I found this using a Google search for....VK_NUMLOCK, Delphi
    :
    : Could be something better, but it works for me.
    :
    : James
    :
    :
    : : How can i detect the state of the insert key and NumLock key when a form shows. I would then like to toggle the text INS and NUM in the status bar panels.
    : : Thanx
    : :
    : :
    :
    :
    :
    :
Sign In or Register to comment.