Insert and NumLock key when form shows - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Insert and NumLock key when form shows

rajsharajsha Posts: 75Member
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 Posts: 105Member
    [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 Posts: 75Member
    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.