用两个ToolButton连同一个PopupMenu
我用两个ToolButton连同一个PopupMenu,
TooButton的Style设为tbsDropDown,
可是当PopupMenu弹出时,我不知道是哪个ToolButton激发的啊!
[解决办法]
在公用的PopupMenu的OnPopup事件中判断:
void __fastcall TForm1::PopupMenu1Popup(TObject *Sender)
{
TPoint pt = ScreenToClient(Mouse->CursorPos);
TControl *c = ToolBar1->ControlAtPos(pt, true, true);
if (c)
Caption = String().sprintf(TEXT("触发的按钮是: %s"), c->Name);
}