Board index » delphi » Displaying CapsLock, Insert, NumLock keys status in the status bar

Displaying CapsLock, Insert, NumLock keys status in the status bar

Hi everybody.
I am new in Delphi programming, and trying to develop simple text
editor.

I have problems with displaying CapsLock, Insert, NumLock keys status in
the status bar.
Can somebody give me a reference to a book or/and application with a
source code for this problem?

Thanks in advance.

Efim

 

Re:Displaying CapsLock, Insert, NumLock keys status in the status bar


Quote
Efim Shvartsburg <e...@concentric.net> wrote:
> I have problems with displaying CapsLock, Insert, NumLock keys status in
> the status bar.

Use the API function GetKeyState().  For example, to test NumLock, you would
do something like:

if Odd(GetKeyState(VK_NUMLOCK)) then
  ShowMessage('NumLock is on')
else
  ShowMessage('NumLock is off');

Use VK_CAPTIAL for Caps Lock and VK_SCROLL for Scroll Lock.

Regards,
Brad
bstow...@pobox.com
Free Delphi Stuff:  http://www.pobox.com/~bstowers/delphi/

Re:Displaying CapsLock, Insert, NumLock keys status in the status bar


Quote
Brad Stowers wrote:

> Efim Shvartsburg <e...@concentric.net> wrote:

> > I have problems with displaying CapsLock, Insert, NumLock keys status in
> > the status bar.

> Use the API function GetKeyState().  For example, to test NumLock, you would
> do something like:

> if Odd(GetKeyState(VK_NUMLOCK)) then
>   ShowMessage('NumLock is on')
> else
>   ShowMessage('NumLock is off');

> Use VK_CAPTIAL for Caps Lock and VK_SCROLL for Scroll Lock.

> Regards,
> Brad
> bstow...@pobox.com
> Free Delphi Stuff:  http://www.pobox.com/~bstowers/delphi/

By chance do you know how to set the state of these keys?  Something
like SetKeyState().  I see there is SetKeyboardSate() but that doesn't
allow this.

Thanks,
Tony

Other Threads