Better moving form

Better moving form

unit Unit1;

interface

uses
  Windows,
  Messages,
  Forms;

type
  TForm1 = class(TForm)
  protected
    procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  // Call default procedure
  inherited;

  // Modify result to make windows think we're
  // clicking on the titlebar when we're actually
  // clicking on the client area...
  if Msg.Result = HTCLIENT then
    Msg.Result := HTCAPTION;
end;

end.