Detecting whether a pop-up menu is visible

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.
LVL 8
gmayoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wim ten BrinkSelf-employed developerCommented:
What's wrong with checking the OnPopup event of the popup menu?
0
Wim ten BrinkSelf-employed developerCommented:
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
gmayoAuthor Commented:
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Slick812Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wim ten BrinkSelf-employed developerCommented:
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
gmayoAuthor Commented:
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
Wim ten BrinkSelf-employed developerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Internet Marketing

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.