窗口最小化时触发一个WM_SYSCOMMAND消息.Delphi并没有封装,需要自己调用,也就是挡截Windows消息. 给你个触发最小化的例子 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) private { Private declarations } public { Public declarations } procedure GetSysCom(var msg: TMessage); message WM_SYSCOMMAND; end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.GetSysCom(var msg: TMessage); begin if msg.WParamLo = SC_MINIMIZE then begin ShowMessage('菜单最小化被触发') end else begin DefWindowProc(self.Handle, WM_SYSCOMMAND, msg.WParam, msg.LParam); end; end;end.
ShowWindow(handle, SW_SHOW); SetWindowLong(Application.Handle, GWL_EXSTYLE, not (GetWindowLong(Application.handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW));
在ApplicationEvents的OnMinimize里加:
ShowWindow(Application.Handle,SW_HIDE);
在TRxTrayIcon的OnClick中加
Application.Restore;
ShowWindow(Application.Handle,SW_SHOW);
Application.BringToFront;
给你个触发最小化的例子
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure GetSysCom(var msg: TMessage); message WM_SYSCOMMAND;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.GetSysCom(var msg: TMessage);
begin
if msg.WParamLo = SC_MINIMIZE then
begin
ShowMessage('菜单最小化被触发')
end
else
begin
DefWindowProc(self.Handle, WM_SYSCOMMAND, msg.WParam, msg.LParam);
end;
end;end.
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW));