Board index » cppbuilder » TPopupMenu and Close Event

TPopupMenu and Close Event


2005-12-09 02:20:17 AM
cppbuilder74
Is there any way to capture/create an OnClose event for a
TPopupMenu? I am highlighting a series of images based on the
mouse's right-click and want to remove the highlight after the
popup menu closes.
Thanks for your help.
 
 

Re:TPopupMenu and Close Event

"Brian" < XXXX@XXXXX.COM >wrote in message
Quote
Is there any way to capture/create an OnClose event
for a TPopupMenu?
Not from TPopupMenu itself, no. You would have to derive a new component
from TPopupMenu and override the virtual Popup() method. Popup() iswhat
actually displays the menu, and does not return until the menu is closed.
For example:
class TMyPopupMenu : public TPopupMenu
{
private:
TNotifyEvent FOnClose;
protected:
virtual void __fastcall DoClose(void);
public:
__fastcall TMyPopupMenu(TComponent *Owner);
virtual void __fastcall Popup(int X, int Y);
__published:
__property TNotifyEvent OnPopupClose = {read=FOnClose,
write=FOnClose};
};
__fastcall TMyPopupMenu::TMyPopupMenu(TComponent *Owner)
: TPopupMenu(Owner)
{
}
void __fastcall TMyPopupMenu::DoClose(void)
{
if( FOnClose )
FOnClose(this);
}
void __fastcall TMyPopupMenu::Popup(int X, int Y)
{
TPopupMenu::Popup(X, Y);
DoClose();
}
Gambit