希望你满意:
procedure OnMinimize(Sender: TObject);
procedure TaskIcoMsgDo(var Msg : TMessage); Message CM_nTaskIcoMsg;
procedure TForm2.FormCreate(Sender: TObject);
var SL:TStringList;
i,j:Integer;
P
FileProperty;
PT
TermInfo;
SQL:String;
begin
Icon.Assign(Application.Icon);
New(FpNotify);
with FpNotify^ do
begin
Wnd := Handle; //主窗体句柄
uID := 0; //内部标识,可设为任意数
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Application.Icon.Handle; //图标
//提示字符串
StrPCopy(szTip,Application.Title);
szTip:='File Monitor';
uCallbackMessage := CM_nTaskIcoMsg; //回调函数消息
end;
Shell_NotifyIcon(NIM_ADD, FpNotify);
{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
{设置最小化事件}
Application.OnMinimize:=OnMinimize;
end;
procedure TForm2.TaskIcoMsgDo(var Msg: TMessage);
var mousept: TPoint;
begin
if Msg.LParam = WM_RBUTTONDOWN then begin
getcursorpos(mousept);
popupmenu1.popup(mousept.x, mousept.y);
end;
if Msg.LParam <> WM_LBUTTONDBLCLK then EXIT; //双击图标,显示(隐藏)窗口
Self.Visible:= true;
if IsIconic(Handle) then
ShowWindow(Handle, SW_RESTORE)
else
BringWindowToTop(Handle);
SetForegroundWindow(Handle);
end;
procedure TForm2.OnMinimize(Sender: TObject);
begin
if IsWindowEnabled(Handle) then
Hide;
end;
同时加一个PopupMenu,会出现菜单