标签:style blog http color 使用 io for 2014
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
ApplicationEvents1: TApplicationEvents;
procedure FormResize(Sender: TObject);
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject);
begin
with StatusBar1 do
begin
Panels[0].Width:=Form1.Width - Panels[1].Width -Panels[2].Width-Panels[3].Width -50;
end;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if GetKeyState(VK_CAPITAL) <> 0 then
StatusBar1.Panels[1].Text := ‘ CAP‘
else
StatusBar1.Panels[1].text:=‘‘;
if GetKeyState(VK_NUMLOCK) <> 0 then
StatusBar1.Panels[2].Text := ‘ NUM‘
else
StatusBar1.Panels[2].Text := ‘‘;
if GetKeyState(VK_SCROLL) <> 0 then
StatusBar1.Panels[3].Text := ‘ SCRL‘
else
StatusBar1.Panels[3].Text := ‘‘;
End;
end.
可以调用Win API的Getkeyboardstate()函数。
常量 按键名称
VK_INSERTI nsert键
VK_NUMLOCK Num Lock键
VK_CAPITAL Caps Lock键
VK_SCROLL Scroll Lock键
键盘缓冲区每一位都有一位特定的格式,对于状态键来说,最低位是1时表示状态键处于ON状态,你可以使用odd()函数来确定这一位的状态,以下是一个简单的例子请参考。例子中放置一个Timer控件、一个StayusBar1状态条。
检测Insert、Capslock、NumLock、ScrollLock状态键的状态,布布扣,bubuko.com
检测Insert、Capslock、NumLock、ScrollLock状态键的状态
标签:style blog http color 使用 io for 2014
原文地址:http://www.cnblogs.com/xe2011/p/3876120.html