bitbtn如何建立双击事件?如何建立右键事件?(100分)

  • 主题发起人 主题发起人 rongtang
  • 开始时间 开始时间
R

rongtang

Unregistered / Unconfirmed
GUEST, unregistred user!
如题:bitbtn正常只有单击事件.bitbtn如何建立双击事件?如何建立右键事件?
 
恐怕不好弄。
 
右键
procedure TForm1.BitBtn1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if Button=mbRight then
showmessage('ok')
end;
 
{为TBitBtn增加鼠标双击事件}
unit Unit2;
interface
uses
windows,SysUtils, Classes, Messages, Buttons;
type
TBitBtnA = class(TBitBtn)
private
{ Private declarations }
FOnMouseDBClick: TNotifyEvent;
procedure FSetOnMouseDBClick(value: TNotifyEvent);
procedure CMMouseDBClick (var Message: TMessage);
message WM_LBUTTONDBLCLK;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property OnDBClick: TNotifyEvent read FOnMouseDBClick write FSetOnMouseDBClick;
end;

procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyControls', [TBitBtnA]);
end;

procedure TBitBtnA.CMMouseDBClick;
begin
if Assigned(FOnMouseDBClick) then
FOnMouseDBClick(Self);
end;

procedure TBitBtnA.FSetOnMouseDBClick(value: TNotifyEvent);
begin
if @FOnMouseDBClick <> @value then
FOnMouseDBClick := Value;
end;

end.
 
继承bitbtn,增加新功能,做成控件.应该也只能这样做了.
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
816
SUNSTONE的Delphi笔记
S
S
回复
0
查看
735
SUNSTONE的Delphi笔记
S
后退
顶部