截获标题栏按钮事件

改写 procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
消息处理函数。

其中 TWMSysCommand 定义如下:

TWMSysCommand = packed record
Msg: Cardinal;
case CmdType: Longint of
SC_HOTKEY: (
ActivateWnd: HWND);
SC_KEYMENU: (
Key: Word);
SC_CLOSE, SC_HSCROLL, SC_MAXIMIZE, SC_MINIMIZE, SC_MOUSEMENU, SC_MOVE,
SC_NEXTWINDOW, SC_PREVWINDOW, SC_RESTORE, SC_SCREENSAVE, SC_SIZE,
SC_TASKLIST, SC_VSCROLL: (
XPos: Smallint;
YPos: Smallint;
Result: Longint);
end;

例: 
procedure TBrxMainForm.WMSysCommand(var Message: TWMSysCommand);
begin
if (Message.CmdType = SC_CLOSE)
or (Message.CmdType = SC_MINIMIZE)
or (Message.CmdType = SC_MOUSEMENU)
or (Message.CmdType = SC_NEXTWINDOW)
or (Message.CmdType = SC_PREVWINDOW) then
begin
inherited;
end;
...
end;

原文地址:https://www.cnblogs.com/spiritofcloud/p/3978315.html