unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure abc(var msg:TWMNCHitTest); //自定义消息处理过程声明
message wm_nchittest;
{用于消息处理的过程必须满足下列 3 个条件:
* 这个过程必须是一个对象中的方法。
* 这个过程必须有一个 Var 参数,变量的类型是 TMessage 或其他特殊的消息记录。
* 声明这个过程时,必须使用 Message 指示符,后面是要处理的消息常量值。
下面是声明一个处理 WM_PAINT 消息的过程代码:
Procedure WMPaint (var Msg: TWMPaint); message WM_PAINT;
注意,给用于消息处理的过程命名时应采用这样的约定:过程名与消息的标识符一致,但不要全
部大写,也不要有下划线。}
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.abc(var msg:TWMNCHitTest); //自定义消息处理过程的实现
begin
inherited;
if (htclient=msg.Result) then
msg.Result:=HTCAPTION;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
end.