?
Solved

PopupMenu + ShellNotifyIcon

Posted on 1998-12-19
4
Medium Priority
?
224 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 600 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

764 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