Solved

Set NumLock State in Delphi 2.0

Posted on 1998-09-21
2
417 Views
Last Modified: 2010-05-18
How can I set the State of the NumLock Key in Windows 95 and NT 4.0? I tried the version listed in the win32 help file - it works with CapsLock and ScrollLock - but not with the NumLock. Does this depend on the manufactor of the PC?
Please give a "clean" solution - if possible without hardware direct access. (PTM@Datacomm.ch)
0
Comment
Question by:ptmcomp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
duke_n earned 100 total points
ID: 1340480
hi !
I had this problem before I found this somewhere.
Let's say you want to change the numlock state to the opposite:

procedure TMyForm.Button1Click(Sender: TObject);
  Var
    KeyState  :  TKeyboardState;
  begin
    GetKeyboardState(KeyState);
    if (KeyState[VK_NUMLOCK] = 0) then
      KeyState[VK_NUMLOCK] := 1
    else
      KeyState[VK_NUMLOCK] := 0;
    SetKeyboardState(KeyState);
  end;

0
 
LVL 10

Author Comment

by:ptmcomp
ID: 1340481
I'm surprised because in the winapi help is written that this does'nt work but indeed it does. Thanks for your prompt answer.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question