Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set NumLock State in Delphi 2.0

Posted on 1998-09-21
2
Medium Priority
?
428 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
2 Comments
 
LVL 1

Accepted Solution

by:
duke_n earned 300 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

971 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