bcoleman
asked on
Closing a TPopupMenu used with TTrayIcon
I am using a TTrayIcon with a TPopupMenu and when I right click on the trayicon my popup menu comes up like it is supposed to, but when I click off it. I click on some other part of the screen. I want it to go away like so many other applications do. Is there a way to do this?
ASKER
How and what do I connect this procedure to?
ASKER
How and what do I connect this procedure to?
Connect the procedure to your form.
My example shows:
TfrmView.IconCallBackMessa ge( var Mess : TMessage );
should read
TfrmMain.IconCallBackMessa ge( var Mess : TMessage );
Sorry for the mixup.
Chad
My example shows:
TfrmView.IconCallBackMessa
should read
TfrmMain.IconCallBackMessa
Sorry for the mixup.
Chad
ASKER
I added the procedure and it is never involked. I added application.messagebox to see if the procedure was ran, and it never came up.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for everones help!!!
Try adding this procedure to your form.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI,
Menus, StdCtrls, ExtCtrls;
type
TfrmMain = class(TForm)
PopupMenu1: TPopupMenu;
private
ResDLLMod: THandle;
public
procedure IconCallBackMessage( var Mess : TMessage ); message WM_USER + 100;
end;
procedure TfrmView.IconCallBackMessa
var pt: TPoint;
sEventLog : String;
begin
case Mess.lParam of
WM_LBUTTONDBLCLK : sEventLog := 'Left Double Click';
WM_LBUTTONDOWN : begin
sEventLog := 'Left Down';
if (clickFlg = true) then
begin
clickFlg := false;
PopupMenu1.Free;
end;
end;
WM_LBUTTONUP : sEventLog := 'Left Up';
WM_MBUTTONDBLCLK : sEventLog := 'M Dbl';
WM_MBUTTONDOWN : sEventLog := 'M D';
WM_MBUTTONUP : sEventLog := 'M U';
WM_MOUSEMOVE : sEventLog := 'movement';
WM_MOUSEWHEEL : sEventLog := 'Wheel';
WM_RBUTTONDBLCLK : sEventLog := 'r dbl';
WM_RBUTTONDOWN : begin
clickFlg := true;
GetCursorPos(pt);
SetForegroundWindow(frmMai
PopupMenu1.Popup(pt.x, pt.y);
sEventLog := 'r down';
end;
WM_RBUTTONUP : sEventLog := 'r up';
end;
end;
==========================
Chad