Solved

PopupMenu + ShellNotifyIcon

Posted on 1998-12-19
4
222 Views
Last Modified: 2010-04-04
Me again...
Now I use a TShellNotifyIcon.
some code:

private
  procedure WndProc ( var Msg: TMessage ); override;
end;

procedure TfrmMain.WndProc ( var Msg: TMessage );
var       pos: TPoint;
begin
     case Msg.Msg of
     WM_User + 1 :
        case Msg.LParam of
             WM_RBUTTONDOWN:
                begin
                     GetCursorPos ( pos );
                     mnuMain.Popup ( pos.x, pos.y );
                end;
             WM_LBUTTONDOWN:
                begin
                    //still to do
                end;
        end;
     end;
     inherited;
end;

everything's working fine, except to the fact, that when the mnuMain.Popup function is called, it doesn't take it back. I mean: when you open a popup-menu by a right-click onto an Icon in the Shell_NotificationArea and then click onto the Desktop or onto the window of another app, the popup-menu disapears. Well, my popup window does not disapear. Why ?
I did already try

begin
  Application.ProcessMessages;
  ShowWindow ( Application.Handle, SW_HIDE );
end.

at the end of my code. Still, the popup-menu stays visible.
Well, at least until you move the cursor over it again. If you clicked onto the desktop before ( lost focus ) and then move the cursor to the still visible popup-menu, then it disapears.
0
Comment
Question by:Oli2
[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
  • 2
4 Comments
 
LVL 1

Author Comment

by:Oli2
ID: 1351990
okay, I figured something out:

I placed a TTimer with TTimer.Interval := 10 onto my form and the TTimer.OnTimer event:

procedure TfrmMain.Timer.OnTimer ( Sender: TObject );
begin
  Application.ProcessMessages;
end;

it works now.
Anybody better ideas ??

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1351991
Oli,

use these two functions before showing the popup menu:

SetForegroundWindow(Application.Handle);
Application.ProcessMessages;

Hmmm. This works under win95. Have not tested it with win98. Win98 behaves a little bit different when calling SetForegroundWindow. Please just try it.

Regards... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
ID: 1351992
Madshi => cool, it works perfect, at least with Win95. I'll test it with Win98 some other time, that's not so important.
How about setting your comment to an answer?
Or do you think, you already have enough points ?  ;-)

Gruß, Oli
0
 
LVL 20

Accepted Solution

by:
Madshi earned 150 total points
ID: 1351993
No, I don't think so...  :-)

Thanx for the points.

Regards... Madshi.

P.S: Und noch einer aus Deutschland...
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 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