Solved

Closing menu opened by Tray icon

Posted on 1998-01-07
2
156 Views
Last Modified: 2012-05-04
If you create a program that resides in the tray that responds to mouse messages and opens a pop-up menu when right-clicked, how do you make the menu close if the user clicks OUTSIDE the menu? Currently, only messages generated inside the menu are sent via the callback.
0
Comment
Question by:nslip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1355734
Try the following when you pop your popup menu up:

SetForegroundWindow(Self.Handle);
try
      PopupMenu.Popup(X, Y);
finally
      SetForegroundWindow(Self.Handle);
end;

(Self.Handle is the tray component's handle.)

Regards,
JB
0
 

Author Comment

by:nslip
ID: 1355735
For some reason, in CBuilder I had to call the Popup routine twice or the menu would only re-appear after the second right-click if the first left-click was outside the menu. The code of the form's FormMouseMove method looks like this now:

if (X == WM_RBUTTONUP) {
   GetCursorPos(&pos);
   SetForegroundWindow(Handle);
   try {
      PopupMenu1->Popup(pos.x,pos.y-20);
      PopupMenu1->Popup(pos.x,pos.y-20);
   } catch(...) {
      SetForegroundWindow(Handle);
   }
}

Thanks JimBob!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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