home *** CD-ROM | disk | FTP | other *** search
- unit shift;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ComCtrls, StdCtrls;
-
- type
- TForm1 = class(TForm)
- SBar: TStatusBar;
- RichEdit1: TRichEdit;
- procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure RichEdit1KeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure ShowShiftStates;
- procedure ShowToggleStates;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.ShowShiftStates;
- begin
- if (GetKeyState( vk_Control ) < 0) then
- SBar.Panels[0].Text := 'CTRL DOWN'
- else
- SBar.Panels[0].Text := 'CTRL UP';
- if (GetKeyState( vk_Menu ) < 0) then { vk_Menu is the constant for Alt! }
- SBar.Panels[1].Text := 'ALT DOWN'
- else
- SBar.Panels[1].Text := 'ALT UP';
- if (GetKeyState( vk_Shift ) < 0) then
- SBar.Panels[2].Text := 'SHIFT DOWN'
- else
- SBar.Panels[2].Text := 'SHIFT UP';
- end;
-
- procedure TForm1.ShowToggleStates;
- var
- s : string;
- begin
- s := 'Numlock';
- if (GetKeyState( vk_NumLock ) < 0) then
- s := s + '[DOWN]'
- else
- s := s + '[ UP ]';
- if Bool(GetKeyState( vk_NumLock ) and 1) then
- s := s + ' ON '
- else
- s := s + ' OFF ';
- s := s + 'Capslock';
- if (GetKeyState( vk_Capital ) < 0) then
- s := s + '[DOWN]'
- else
- s := s + '[ UP ]';
- if Bool(GetKeyState( vk_Capital ) and 1) then
- s := s + ' ON '
- else
- s := s + ' OFF ';
- if Bool(GetKeyState( vk_Insert ) and 1) then
- s := s + ' INSERT '
- else
- s := s + ' OVERTYPE ';
-
- SBar.Panels[3].Text := s;
-
- end;
-
-
- procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if Key = vk_F2 then Close;
- ShowShiftStates;
- ShowToggleStates;
- end;
-
- procedure TForm1.RichEdit1KeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- ShowShiftStates;
- ShowToggleStates;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- ShowShiftStates;
- ShowToggleStates;
- end;
-
- end.
-