Mega Code Archive

 
Categories / Delphi / OOP
 

How to add dblclick event

If it has TControl as an ancestor then put: published property OnDblClick; into your class declaration. Otherwise use the following code to capture the message: type TYourClass=class(WhatEverclass you want) private FOnDblClick : TNotifyEvent; procedure WMDblClick(var :TWMLButtonDBLCLK); message WM_LBUTTONDBLCLK; // .. public OnDblClick : TNotifyEvent read FOnDblClick write FOnDblClick; end; // if you don't want a property OnDblClick procedure TYourClass.WMDblClick(var :TWMLButtonDBLCLK); begin inherited; // do your stuff here end; // or: if you do want a property OnDblClick procedure TYourClass.WMDblClick(var :TWMLButtonDBLCLK); begin inherited; if Assigned (FOnDblClick) FOnDblClick(Self); end;