已有定义的系统命令常数(感觉有些有问题):
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