Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Closing menu opened by Tray icon

Posted on 1998-01-07
2
Medium Priority
?
159 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 400 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

618 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