Button Click

Hi All,

I have an application that is not visible to the user except within the system tray.

When the user clicks on the icon in the system tray, a popup menu appears. How do I make the popup close when the user clicks anywhere else except on one of the menu options?

Thanks in advance,
Chad
dhertzfeAsked:
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.

RBertoraCommented:
How about just using a timer
and hiding it say after 5 seconds or
some timeout interval:
to hide it use

showwindow(popupmenu1.Handle,SW_HIDE);

Rob ;-)
0
intheCommented:
Just before you call PopupMenu.Popup, make an API call:
 
      SetForegroundWindow(Handle);
 
This will force your application to get focus and, upon losing the focus (by clicking on the desktop), the popup will close correctly.
 
Regards Barry
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
JaymolCommented:
I had a crappy systemtray component that had this problem.  I couldn't be bothered trying to sort it out, so I just put a "Close Menu" option on the menu and told people it was a special feature (Keeping the menu open) and no other Windows program did it!  People thought it was cool!

Just leave the event handler for "Close Menu" blank.

I know this isn't an answer, but it works.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

RBertoraCommented:
How about using a ttimer to count down a timeout and then hiding it yourself with:


  showwindow(popupmenu1.Handle,SW_HIDE);

Rob ;-)
0
dhertzfeAuthor Commented:
Thanks Barry it works perfectly.
0
intheCommented:
glad to hear it as i didnt test first  ;-)
0
RBertoraCommented:
Good one Inthe!
Rob ;-)
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
Delphi

From novice to tech pro — start learning today.