?
Solved

Detecting whether a pop-up menu is visible

Posted on 2004-11-03
7
Medium Priority
?
1,134 Views
Last Modified: 2013-11-28
I have a listbox which is dynamic in its contents. A context-sensitive pop-up menu shows when the user right-clicks on an entry. I need to stop updating the listbox whilst the pop-up menu is visible, to avoid the user selecting an option for an item other than the one he selected.

Trouble is: how? I can tell when the pop-up menu gets shown, but not when it gets hidden.

There are a couple of solutions in EE already, but they're messy and I'm not 100% convinced they will catch all the events which cause the pop-up menu to close (task swap, minimise, another active window, etc).

Any simple, foolproof solution for D7Pro?

Cheers

Geoff M.
0
Comment
Question by:gmayo
  • 4
  • 2
7 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12484496
What's wrong with checking the OnPopup event of the popup menu?
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12484577
Oh, I see your problem now... :-) Well, you could try to capture the messages that are sent to your application and have them checked by your application first, before you allow the popup to handle the message. What you have to do is check if you receive a WM_COMMAND message, indicating a popup command is executed or a WM_MENUSELECT which indicates that a popup item is selected. Or WM_CANCELMODE to see if the popup gets cancelled. WM_CONTEXTMENU when it pops up. Just capture these messages before your popup receives them, check if you have to cancel the updates or not and then finally call the inherited messagehandler to finalize the message.
0
 
LVL 8

Author Comment

by:gmayo
ID: 12484841
So is WM_CANCELMODE sent *every* time the pop-up menu closes - or are other messages sent which imply that the menu is closing?

Geoff M.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Accepted Solution

by:
Slick812 earned 500 total points
ID: 12486270
hello gmayo , the following EE question may give you some info for what you are asking - -


http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21175629.html#12368925
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12488731
Well, WM_CANCELMODE is sent every time a menu is closed and in general you would only have one popup or other menu open.
0
 
LVL 8

Author Comment

by:gmayo
ID: 12496115
Thanks Alex, but Slick's pointer to a previous solution seems bulletproof and used code I could just cut'n'paste.

Cheers

Geoff M.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12497086
Lol. I should have thought about that too. :-)
Then again, I often use the Windows API to create popup menu's since most applications I work on are very small or are just simple trayicon applications. Sometimes I'm just too deep in the API to notice those simpler solutions... (But hey, I do tend to create very small exe's...)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We aren’t perfect, just like everyone else.  Check out the email errors our community caught and learn the top errors every email marketer should avoid.
Whoever said that “a picture is worth one thousand words” observed a fact that can dramatically affect your marketing success. Most people tend to learn visually, so many publishers commonly acknowledge the effectiveness of visual learning by using…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question