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

x
?
Solved

PopupMenu + ShellNotifyIcon

Posted on 1998-12-19
4
Medium Priority
?
225 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

609 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