不知道你是怎么写了,今天试了一下 我用的是TRZTrayIcon控件,是可以的<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, RzTray, StdCtrls, Menus;<br><br>type<br> TForm1 = class(TForm)<br> RzTrayIcon1: TRzTrayIcon;<br> Button1: TButton;<br> PopupMenu1: TPopupMenu;<br> N1: TMenuItem;<br> N2: TMenuItem;<br> procedure FormCreate(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br> procedure N1Click(Sender: TObject);<br> procedure N2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> NowIsShow: Boolean;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> NowIsShow := True; //不允许关闭<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> NowIsShow := false; //关闭<br>end;<br><br>procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br>begin<br> if NowIsShow then<br> begin<br> RzTrayIcon1.MinimizeApp;<br> CanClose := False;<br> end<br> else<br> CanClose := True;<br>end;<br><br>procedure TForm1.N1Click(Sender: TObject); //快捷菜单的'退出'<br>begin<br> NowIsShow := False;<br> Close;<br>end;<br><br>procedure TForm1.N2Click(Sender: TObject); //快捷菜单的'打开'<br>begin<br> RzTrayIcon1.RestoreApp;<br>end;<br><br>end.