已有定義的系統命令常數(感覺有些有問題):
SC_SIZE = 61440;
SC_MOVE = 61456;
SC_MINIMIZE = 61472;
SC_MAXIMIZE = 61488;
SC_NEXTWINDOW = 61504;
SC_PREVWINDOW = 61520;
SC_CLOSE = 61536;
SC_VSCROLL = 61552;
SC_HSCROLL = 61568;
SC_MOUSEMENU = 61584;
SC_KEYMENU = 61696;
SC_ARRANGE = 61712;
SC_RESTORE = 61728;
SC_TASKLIST = 61744;
SC_SCREENSAVE = 61760;
SC_HOTKEY = 61776;
SC_DEFAULT = 61792;
SC_MONITORPOWER = 61808;
SC_CONTEXTHELP = 61824;
SC_SEPARATOR = 61455;
SC_ICON = SC_MINIMIZE;
SC_ZOOM = SC_MAXIMIZE;
未定義的系統命令常數:
61441: 拖動左邊框
61442: 拖動右邊框
61443: 拖動上邊框
61444: 拖動左上角
61445: 拖動右上角
61446: 拖動下邊框
61447: 拖動左下角
61448: 拖動右下角
61458: 拖動標題欄
61558: 橫向滾動條滾動
61574: 雙擊橫向滾動條
61575: 縱向滾動條滾動
61559: 雙擊縱向滾動條
61587: 點擊最小化圖標
61490: 在非最大化時雙擊標題欄
61730: 在最大化時雙擊標題欄
//可能還有...
WM_SYSCOMMAND 是做什麼的? 咱們先看看把 WM_SYSCOMMAND 消息封鎖掉是什麼樣子吧:
代碼文件:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDblClick(Sender: TObject);
protected
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const
br = #13#10;
begin
Label1.AutoSize := True;
Label1.Caption :=
'此窗體屏蔽了 SYSCOMMAND 消息!' + br +
'將無法改變窗體大小;' + br +
'將無法移動窗體;' + br +
'將無法最大、最小化窗體;' + br +
'也將無法通過常規途徑關閉窗體.' + br +
'' + br +
'所以提供了雙擊窗體關閉的功能.';
Label1.OnDblClick := OnDblClick;
end;
procedure TForm1.FormDblClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
// inherited; {取消這句的注釋, WM_SysCommand 就活了}
end;
end.
窗體文件:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClIEntHeight = 172
ClIEntWidth = 264
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDblClick = FormDblClick
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 24
Width = 89
Height = 33
Caption = 'Label1'
end
end