首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 读书 | 代码
亲,您未登录哦! 登录 | 注册

关于控制CAPS LOCK按键

打印文章

分享到:
用于function中

const
   SCROLLLOCK = 1;
   NUMLOCK    = 2;
   CAPSLOCK   = 4;

var
   Status:  Byte;
   PntK:    ^Byte;
begin
     PntK := Ptr($40, $97); {directly point in
memory}
     Status := Byte(PntK^); {read the status}
     if (NUMLOCK and Status) = NUMLOCK then {if NUM
LOCK is on}
         Status := Status and (255 - NUMLOCK) {turn it
off}
     else
         Status := Status or 2; {turn it
on}
     Pntk^ := Status; {poke in
memory (don't works)}
end;

A:
I use this procedures to turn on the caps lock if it isn't
already on when
the user enters my DBloockup combo.  This gets rid of the
nasty problem
of case-sensitive indexes.

procedure TMainForm.StudentLookupEnter(Sender: TObject);
Var Level : Integer;
    KeyState : TKeyBoardState;
begin
  {check if caps-lock is on - if not turn it on}
  Level := GetKeyState(VK_CAPITAL);
  GetKeyboardState(KeyState);
  CapsLockStatus := KeyState;
  If Level = 0 then
    begin
      KeyState[VK_CAPITAL] := 1;
      setKeyboardState(KeyState);
    end;
end;

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章