R rongtang Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-30 #1 如题:bitbtn正常只有单击事件.bitbtn如何建立双击事件?如何建立右键事件?
Q q2 Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-30 #3 右键 procedure TForm1.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button=mbRight then showmessage('ok') end;
右键 procedure TForm1.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button=mbRight then showmessage('ok') end;
Q q2 Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-30 #4 {为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.
{为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.
F fanboynet Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-30 #5 继承bitbtn,增加新功能,做成控件.应该也只能这样做了.