在可視控件的onMouseDown事件中如何判斷鼠標按下的是左鍵還是右鍵。(50分)

  • 主题发起人 主题发起人 李維
  • 开始时间 开始时间

李維

Unregistered / Unconfirmed
GUEST, unregistred user!
請舉例說明
 
我是侯捷:)

procedure TForm1.Button1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
showmessage('鼠标左键');
end;
mbleft 鼠标左键
mbRight 鼠标右键
mbMiddle 鼠标中间滚轮
 
如何給一個可視控件增加鼠標雙擊事件。請舉例說明。
 
如果它的父类有双击事件,就不用加了。
如果没有,应该要用到消息吧。其实你不如看看VCL的源码。

procedure TControl.WMLButtonDblClk(var Message: TWMLButtonDblClk);
begin
SendCancelMode(Self);
inherited;
if csCaptureMouse in ControlStyle then MouseCapture := True;
if csClickEvents in ControlStyle then DblClick;
DoMouseDown(Message, mbLeft, [ssDouble]);
end;
 
請問在哪裡可以看到VCL的源码
 
有点业余了吧。
 
zw84611的方法就可以實現。
 
与zw84611一样,事件里的参数很有用,注意看一下帮助
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
823
import
I
I
回复
0
查看
555
import
I
后退
顶部