如何为TShape增加双击事件
在BCB6.0中TShape没有单击或双击事件,如何才能在TShape上捕捉这个事件?
[解决办法]
写个新控件, 使双击事件可用.
.h:
private:
void __fastcall ShapeDblClick(TObject *Sender);
.cpp:
class TMyShape : public TShape
{
__published:
__property OnDblClick;
public:
__fastcall TMyShape(TComponent* AOwner) : TShape(AOwner){};
};
TMyShape *ms;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ms = new TMyShape(this);
ms-> OnDblClick = ShapeDblClick;
ms-> Parent = this;
}
//---------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete ms;
}
void __fastcall TForm1::ShapeDblClick(TObject *Sender)
{
ShowMessage( "dbl click ");
}