WM_NCHITTEST 消息演示程序
代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus;
type
TForm1 = class(TForm)
Panel1: TPanel;
MainMenu1: TMainMenu;
file1: TMenuItem;
private
{ Private declarations }
procedure myMsg(var msg:TWMNCHitTest);message WM_NCHITTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{$APPTYPE CONSOLE}
const
arr:array[-2..21] of string=(
'HTERROR',
'HTTRANSPARENT',
'HTNOWHERE',
'HTCLIENT - 客户区',
'HTCAPTION - 标题',
'HTSYSMENU - 系统菜单',
'HTGROWBOX',
'HTMENU - 菜单',
'HTHSCROLL - 水平滚动条',
'HTVSCROLL - 垂直滚动条',
'HTMINBUTTON - 最小化按钮',
'HTMAXBUTTON - 最大化按钮',
'HTLEFT - 左边界',
'HTRIG - 右边界',
'HTTOP - 上边界',
'HTTOPLEFT - 左上角',
'HTTOPRIG - 右上角',
'HTBOTTOM - 下边界',
'HTBOTTOMLEFT - 左下角',
'HTBOTTOMRIG - 右下角',
'HTBORDER',
'HTOBJECT',
'HTCLOSE - 关闭按钮',
'HTHELP');
{ TForm1 }
procedure TForm1.myMsg(var msg: TWMNCHitTest);
var
i:integer;
begin
Inherited;
i:=msg.Result;
Writeln(i,arr[i]);
end;
end.
-------------------------------------------
界面代码:
object Form1: TForm1
Left = 0
Top = 0
Width = 271
Height = 208
AutoScroll = True
Caption = 'WM_NCHITTEST'#28040#24687#28436#31034
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 136
Top = 56
Width = 153
Height = 121
Caption = 'Panel1'
TabOrder = 0
end
object MainMenu1: TMainMenu
Top = 16
object file1: TMenuItem
Caption = 'file'
end
end
end
-------------------------------------------
//另附 WM_NCHITTEST 消息中 Result 参数的所有可能值的列表:
HTERROR = -2;
HTTRANSPARENT = -1;
HTNOWHERE = 0;
HTCLIENT = 1;
HTCAPTION = 2;
HTSYSMENU = 3;
HTGROWBOX = 4;
HTSIZE = HTGROWBOX;
HTMENU = 5;
HTHSCROLL = 6;
HTVSCROLL = 7;
HTMINBUTTON = 8;
HTMAXBUTTON = 9;
HTLEFT = 10;
HTRIGHT = 11;
HTTOP = 12;
HTTOPLEFT = 13;
HTTOPRIGHT = 14;
HTBOTTOM = 15;
HTBOTTOMLEFT = $10;
HTBOTTOMRIGHT = 17;
HTBORDER = 18;
HTREDUCE = HTMINBUTTON;
HTZOOM = HTMAXBUTTON;
HTSIZEFIRST = HTLEFT;
HTSIZELAST = HTBOTTOMRIGHT;
HTOBJECT = 19;
HTCLOSE = 20;
HTHELP = 21;
源代码下载:http://www.rayfile.com/files/f4da2347-17e5-11df-9f9d-0015c55db73d/