unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>Type<br> TClickFlag = (cfNone,cfMouse,cfBroad);<br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> procedure ListBox1Click(Sender: TObject);<br> procedure ListBox1KeyDown(Sender: TObject; var Key: Word;<br> Shift: TShiftState);<br> procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br> private<br> { Private declarations }<br> FClickFlag : TClickFlag;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.ListBox1Click(Sender: TObject);<br>begin<br> Case FClickFlag of<br> cfMouse : showmessage('鼠标触发');<br> cfBroad : showmessage('方向键触发');<br> else showmessage('未知');<br> end;<br>end;<br><br>procedure TForm1.ListBox1KeyDown(Sender: TObject; var Key: Word;<br> Shift: TShiftState);<br>begin<br> if Key in [vk_up,vk_left,vk_right,vk_down] then<br> FClickFlag := cfBroad;<br>end;<br><br>procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br>begin<br> FClickFlag := cfMouse;<br>end;