判断是否shift按键

代码
 1 unit Unit1;
 2 interface
 3 uses
 4   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 5   Dialogs;
 6 type
 7   TForm1 = class(TForm)
 8     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
 9       Shift: TShiftState; X, Y: Integer);
10   private
11     { Private declarations }
12   public
13     { Public declarations }
14   end;
15 var
16   Form1: TForm1;
17 implementation
18 {$R *.dfm}
19 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
20   Shift: TShiftState; X, Y: Integer);
21 begin
22 if [ssleft,ssctrl,ssalt]=shift then
23 messagebeep(0);
24 end;
25 procedure TForm1.FormMouseMove(Sender: TObject; Button: TMouseButton;
26   Shift: TShiftState; X, Y: Integer);
27 begin
28 if (ssleft in shift)and(ssctrl in shift) then
29 左键连着ctrl一起按为真
30 messagebeep(0);
31 end;
32 end.

 

posted @ 2009-12-09 23:55  懒人博客  阅读(243)  评论(0)    收藏  举报