unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Shift >= [ssShift] then
label1.Caption := '你按下了Shift键';
if Shift >= [ssAlt] then
label1.Caption := '你按下了Alt键';
if Shift >= [ssCtrl] then
label1.Caption := '你按下了Ctrl键';
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Shift >= [ssLeft] then
label1.Caption := '你单击鼠标左键';
if Shift >= [ssMiddle] then
label1.Caption := '你单击鼠标中键';
if Shift >= [ssDouble] then
label1.Caption := '你双击了鼠标';
if ssRight in Shift then
label1.Caption := '你单击鼠标右键';
end;
end.
