🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17444

Re: How to get and set the NumLock State?

#17444
From: Rodolfo Frino - Stargate Softwar...
Date: Mon, 24 Mar 2003 23:09
43 lines
2057 bytes
From MS pages:

   void SetNumLock(bool State)
   {
      BYTE keyState[256];

      GetKeyboardState((LPBYTE)&keyState);

      if( (State && !(keyState[VK_NUMLOCK] & 1)) ||
          (!State && (keyState[VK_NUMLOCK] & 1)) )
      {
      // Simulate a key press
         keybd_event(VK_NUMLOCK, 0x45,
                     KEYEVENTF_EXTENDEDKEY | 0,
                     0);

      // Simulate a key release
         keybd_event(VK_NUMLOCK, 0x45,
                     KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                     0);
      }
   }


void __fastcall TForm1::Button1Click(TObject *Sender)
{
      SetNumLock(true);
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button2Click(TObject *Sender)
{
      SetNumLock(false);
}

Rodolfo

"Phuoc Can HUA" <home+a+t+huaonline.com> wrote in message
news:3e7e4050@newsgroups.borland.com...
> How do I read and change the the state of the NumLock button?
> How can I find out whether the Shift key is pressed and hold (not just in
a
> KeyPress event, but anywhere in program)?
Technical Details
Message-ID: <3e7f98ff@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e7e4050@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,6e8150c928fb21c9
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-24 15:52:05 PST
From: "Rodolfo Frino - Stargate Software" <starcinema@eftel.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e7e4050@newsgroups.borland.com>
Subject: Re: How to get and set the NumLock State?
Date: Tue, 25 Mar 2003 10:09:01 +1100
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 203.129.132.93
Message-ID: <3e7f98ff@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048549631 203.129.132.93 (24 Mar 2003 15:47:11 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail