最简单的办法就是"欺骗"系统,让他认为点中的是窗体的标题行
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
unit Dragmain;interfaceusesSysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,Forms, Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;procedure Button1Click(Sender: TObject);privateprocedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;end;varForm1: TForm1;implementation{$R *.DFM}procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);begininherited; { call the inherited message handler }if M.Result = htClient then { is the click in the client area? }M.Result := htCaption; { if so, make Windows think its }{ on the caption bar. }end;procedure TForm1.Button1Click(Sender: TObject);beginClose;end;end.{ 下面是这个窗体的设置}object Form1: TForm1Left = 203Top = 94BorderIcons = []BorderStyle = bsNoneClientHeight = 273ClientWidth = 427Font.Color = clWindowTextFont.Height = -13Font.Name = SystemFont.Style = []PixelsPerInch = 96TextHeight = 16object Button1: TButtonLeft = 160Top = 104Width = 89Height = 33Caption = CloseTabOrder = 0OnClick = Button1Clickendend(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)