Board index » cppbuilder » How to know if Popup menu is visible or not
Jet
![]() CBuilder Developer |
Jet
![]() CBuilder Developer |
How to know if Popup menu is visible or not2004-01-08 05:32:46 PM cppbuilder19 Hello there! Is there a way of knowing if a popup menu is visible or not, other than using formcontextpopup and popuppoint.x or y? Thanks! --13--@ |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-01-09 03:17:27 AM
Re:How to know if Popup menu is visible or not
"Jet" < XXXX@XXXXX.COM >wrote in message
QuoteHello there! Is there a way of knowing if a popup menu intercepting WM_COMMAND and/or WM_EXITMENULOOP messages manually. Quoteother than using formcontextpopup and popuppoint.x or y? |
Jet
![]() CBuilder Developer |
2004-01-09 07:07:26 AM
Re:How to know if Popup menu is visible or notQuote>other than using formcontextpopup and popuppoint.x or y? value when it popped up? ---13--@ {smallsort} |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-01-09 09:08:20 AM
Re:How to know if Popup menu is visible or not
"Jet" < XXXX@XXXXX.COM >wrote in message
QuoteA follow-up q: Why is it that popuppoint.x still has a Gambit |
Jet
![]() CBuilder Developer |
2004-01-09 09:37:06 AM
Re:How to know if Popup menu is visible or notQuote>... popuppoint.x still has a value even if I used the menu's shortcut? When PopupMenu1 pops up, PopupMenu1->PopupPoint.x = 700, for example. But when PopupMenu1 is no longer visible and I use Ctrl+A, PopupMenu1->PopupPoint.x is still 700. So, I can't use it to determine if the popupmenu is visible. About WM_COMMAND and/or WM_EXITMENULOOP ... can you please give me an idea on how to use these message handlers? Thanks! Jet |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-01-09 01:15:43 PM
Re:How to know if Popup menu is visible or not
"Jet" < XXXX@XXXXX.COM >wrote in message
QuoteWhen PopupMenu1 pops up, PopupMenu1->PopupPoint.x = 700, QuoteSo, I can't use it to determine if the popupmenu is visible. can't do anything else anyway, so what good is detecting the menu if your code wil never run while the menu is actually visible to begin with? Please explain in more detail exactly what you are trying to accomplish. Gambit |
Jet
![]() CBuilder Developer |
2004-01-09 03:09:26 PM
Re:How to know if Popup menu is visible or notQuoteThe PopupPoint property is only updated when Popup() is called to actually Quote
{ TPopupMenu* Menu; Menu = (TPopupMenu*)Sender; if(Menu->PopupComponent == NULL) return; if(PopupMenu1->PopupPoint.x < 0) return; if(Menu->PopupComponent->ClassNameIs("TMyControl")){ PopupMenuItem1->Enabled = true; PopupMenuItem2->Enabled = true; } else{ PopupMenuItem1->Enabled = false; PopupMenuItem2->Enabled = false; } } the first time the shortcut is used, it enters Popup() and the PopupComponent is NULL, so there is no problem with that. However, when the popupmenu pops up and then cancelled so that it is no longer visible, the next time the shortcut is used, it still enters Popup() and the PopupComponent is not NULL anymore. Also, the popuppoint retains its previous value. This causes an access violation, when it reaches the line if(Menu->PopupComponent->ClassNameIs("TMyControl")) ... ... and i need it to enable or disable my menu items. |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-01-10 02:06:44 AM
Re:How to know if Popup menu is visible or not
"Jet" < XXXX@XXXXX.COM >wrote in message
Quote>Why do you need this anyway? menu will ALWAYS be visible immediately afterwards the event handler exiting. There is no reason to test the PopupPoint property or anything else for that matter. Just update your items with the assumption that the menu is visible. That is what the OnPopup event is for - updating the menu when it is being displayed. void __fastcall TMainForm::PopupMenu1Popup(TObject *Sender) { TPopupMenu* Menu = static_cast<TPopupMenu*>(Sender); TMyControl *ctrl = dynamic_cast<TMyControl*>(Menu->PopupComponent) PopupMenuItem1->Enabled = (ctrl != NULL); PopupMenuItem2->Enabled = (ctrl != NULL); } Gambit |