Tuesday, February 14, 2006

Moving forms with no caption

To move a form with no caption, you must override WM_NCHITTEST message, like this:




type

  TForm1 = class(TForm)

  public

    procedure WMNCHitTest(var M: TWMNCHitTest); message WM_NCHitTest;

  end;



var

  Form1: TForm1;



implementation

{$R *.DFM}



procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);

begin

  inherited;

  if M.Result = htClient then {if the mouse clicked on the form}

    M.Result := htCaption; {make windows think that mouse has been clicked on caption}

end;

0 Comments:

Post a Comment

<< Home