procedure TMainForm.MyTrayIconOnClick(var Msg:TMessage);
var
pt:TPoint;
begin
case Msg.lParam of
WM_LBUTTONDOWN:
begin
MainForm.Visible:=true; //look here
Application.BringToFront; //look here
end;
WM_LBUTTONDBLCLK:
begin
end;
WM_RBUTTONDOWN:
begin
end;
end;
end;
procedure Tmain.SeSkinSpeedButton7Click(Sender: TObject);
begin
if findmdiwindow=true then begin
showmessage('请关闭当前窗口');exit;end;
ntida.cbSize := sizeof(tnotifyicondataa);
ntida.wnd := handle;
ntida.uID := iid;
ntida.uFlags := nif_icon + nif_tip + nif_message;
ntida.uCallbackMessage := mousemsg;
ntida.hIcon := Application.Icon.handle;
ntida.szTip := 'Icon';
shell_notifyicona(NIM_DELETE, @ntida);
Application.Terminate;
end;
procedure tmain.mousemessage(var message:tmessage);
var
mousept:tpoint;
begin
inherited;
if message.LParam=wm_rbuttonup then begin
getcursorpos(mousept);
SeSkinPopupMenu1.Popup(mousept.X,mousept.Y);
end;
if message.LParam=wm_lbuttonup then begin
showwindow(handle,sw_show);
showwindow(application.Handle,sw_show);
setwindowlong(application.Handle,gwl_exstyle,not (getwindowlong(application.Handle,gwl_exstyle) or ws_ex_toolwindow and not ws_ex_appwindow));
end;
message.Result:=0;
end;
procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone; //不进行任何动作
ShowWindow(Handle, SW_HIDE); //隐藏窗口
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end;
procedure Tmain.CustomItem53Click(Sender: TObject);
begin
ShowWindow(Handle, SW_show); //显示窗口
ShowWindow(Application.Handle, SW_show);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end;