type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
case Message.CmdType of
SC_MAXIMIZE: ShowMessage('最大化');
SC_MINIMIZE: ShowMessage('最小化');
end;
inherited;
end;
procedure TCustomForm.WMSysCommand(var Message: TWMSysCommand);
begin
with Message do
begin
if (CmdType and $FFF0 = SC_MINIMIZE) and (Application.MainForm = Self) then
Application.WndProc(TMessage(Message))//就是这里,明白?
else if (CmdType and $FFF0 <> SC_MOVE) or (csDesigning in ComponentState) or
(Align = alNone) or (WindowState = wsMinimized) then
inherited;
if ((CmdType and $FFF0 = SC_MINIMIZE) or (CmdType and $FFF0 = SC_RESTORE)) and
not (csDesigning in ComponentState) and (Align <> alNone) then
RequestAlign;
end;
end;