Shell_NotifyIcon简单问题!高手近来,200%结贴!(50分)

  • 主题发起人 主题发起人 InvidentXp
  • 开始时间 开始时间
I

InvidentXp

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么我的拖盘图标弹出来以后用鼠标点别的地方不会消失,怎么别人的就可以?
 
你讲的不太清楚,是弹出的菜单吧
 
系统问题我的也一样!<br>要刷新
 
把代码贴出,这么说怎么知道那得问题
 
unit TrayIcon;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, Menus,shellapi;<br><br>type<br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; PNotifyIconData = ^TNotifyIconDataA;<br>&nbsp; &nbsp; TNotifyIconDataA = record<br>&nbsp; &nbsp; cbSize : DWORD;<br>&nbsp; &nbsp; Wnd : HWND;<br>&nbsp; &nbsp; uID : UINT;<br>&nbsp; &nbsp; uFlags : UINT;<br>&nbsp; &nbsp; uCallbackMessage : UINT;<br>&nbsp; &nbsp; hIcon : HICON;<br>&nbsp; &nbsp; szTip : array [0..63] of AnsiChar;<br>&nbsp; end;<br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; PopupMenu1: TPopupMenu;<br>&nbsp; &nbsp; open1: TMenuItem;<br>&nbsp; &nbsp; close1: TMenuItem;<br>&nbsp; &nbsp; N1: TMenuItem;<br>&nbsp; &nbsp; about1: TMenuItem;<br>&nbsp; &nbsp; procedure FormClose(Sender: TObject; var Action: TCloseAction);<br>&nbsp; &nbsp; procedure open1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure close1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormShow(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; //-------------------------------------------------------------<br>&nbsp; &nbsp; IconData: TNotifyIconData;<br>&nbsp; &nbsp; procedure ShowIcon;<br>&nbsp; &nbsp; procedure IconOnClick(var message:TMessage); message WM_USER+1;<br>&nbsp; &nbsp; Procedure WMSysCommand(Var message : TMessage) ; Message WM_SYSCOMMAND ;<br>&nbsp; &nbsp; //-------------------------------------------------------------<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.IconOnClick( var message: Tmessage);<br>var p : TPoint;<br>begin<br>&nbsp;if (message.lParam = WM_LBUTTONDOWN) then<br>&nbsp;begin<br>&nbsp; &nbsp;ShowWindow(Handle, SW_SHOW );<br>&nbsp;end;<br>&nbsp;<br>&nbsp;if (message.lParam = WM_RBUTTONDOWN) then<br>&nbsp;begin<br>&nbsp; &nbsp;GetCursorPos(p);<br>&nbsp; &nbsp;SetForegroundWindow (Application.Handle); //&lt;----------------------------------------------------注意加上这两句<br>&nbsp; &nbsp;Application.ProcessMessages; &nbsp;//&lt;----------------------------------------------------------------<br>&nbsp; &nbsp;popupmenu1.Popup( p.x ,p.y );<br>&nbsp;end;<br>end;<br><br>Procedure TForm1.WMSysCommand(Var Message : TMessage) ;<br>begin<br><br>&nbsp; if (Message.WParam = SC_MINIMIZE) then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ShowIcon;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; &nbsp;Inherited;<br><br>end;<br><br>procedure TForm1.ShowIcon;<br>begin<br>&nbsp; &nbsp; &nbsp; IconData.cbSize := SizeOf( IconData );<br>&nbsp; &nbsp; &nbsp; IconData.Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; IconData.uID := 1;<br>&nbsp; &nbsp; &nbsp; IconData.uFlags := NIF_ICON &nbsp;or NIF_MESSAGE or NIF_TIP;<br>&nbsp; &nbsp; &nbsp; IconData.uCallBackMessage := WM_USER+1;<br>&nbsp; &nbsp; &nbsp; IconData.hIcon := application.Icon.Handle;<br>&nbsp; &nbsp; &nbsp; IconData.szTip := 'LANChat';<br>&nbsp; &nbsp; &nbsp; Shell_NotifyIcon( NIM_ADD, @IconData );<br>&nbsp; &nbsp; &nbsp; ShowWindow(Handle, SW_HIDE);<br>&nbsp; &nbsp; &nbsp; hide;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; &nbsp;Shell_NotifyIcon( NIM_DELETE, @IconData );<br>end;<br><br>procedure TForm1.open1Click(Sender: TObject);<br>begin<br>&nbsp; Form1.Show;<br>end;<br><br>procedure TForm1.close1Click(Sender: TObject);<br>begin<br>&nbsp; Form1.close;<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br>&nbsp; <br>&nbsp; showwindow(application.handle,sw_hide);<br>&nbsp; <br><br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; showicon;<br>end;<br><br>end.<br>
 
程序运行正常,有什么问题
 
接受答案了.
 
后退
顶部