控件没有mouseup函数。应该怎么弄。
我在使用Scintilla做个简单的源码编辑器。Scintilla本身没有像tpanel一样的mouseup可以调用。我是想右键Scintilla文本框弹出一个TPopupMenu,
Scintilla 控件代码如下:
- C/C++ code
class TScEdit : public TWinControl{protected: virtual void __fastcall CreateParams(Controls::TCreateParams &Params) { TWinControl::CreateParams(Params); CreateSubClass(Params, "Scintilla"); } virtual void __fastcall WndProc(Messages::TMessage &Message) { TWinControl::WndProc(Message); if(Message.Msg == WM_GETDLGCODE) //让窗体接受方向键和TAB键 Message.Result = DLGC_WANTALLKEYS|DLGC_WANTARROWS|DLGC_WANTTAB; if (Message.Msg == WM_RBUTTONUP) { POINT P; GetCursorPos(&P); TPopupMenu *PopupMenux=new TPopupMenu(this); // PopupMenu1->Popup(P.x, P.y); } }public: __fastcall TScEdit(Classes::TComponent* AOwner) :TWinControl(AOwner){;} sptr_t SendEditor(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) { return SendMessage(Handle, iMessage, wParam, lParam); }};
if (Message.Msg == WM_RBUTTONUP)
{ POINT P;
GetCursorPos(&P);
TPopupMenu *PopupMenux=new TPopupMenu(this);
// PopupMenu1->Popup(P.x, P.y);
}
这个可以产生一个PopupMenu,但是我希望能够直接调用窗口中建好的PopupMenu1,请问怎么操作???。
class TForm1 : public TForm
{
__published:// IDE-managed Components
TPopupMenu *PopupMenu1;
TMenuItem *a;
TMenuItem *b;
TMenuItem *c;
[解决办法]
那这里就不用新建了,你懂得。
TPopupMenu *PopupMenux=new TPopupMenu(this);
- C/C++ code
TPopupMenu *PopupMenux=Screen->ActiveForm->PopupMenu;if(PopupMenux ){...}