Board index » delphi » Disable form dragging (caption bar) ?

Disable form dragging (caption bar) ?

Is there a way to prevent the form being dragged by clicking on the
caption bar? Also, preventing the form being maximized when
double-clicking on the caption bar?
 

Re:Disable form dragging (caption bar) ?


Quote
> Is there a way to prevent the form being dragged by clicking on the
> caption bar? Also, preventing the form being maximized when
> double-clicking on the caption bar?

The secret lies in answering the WM_NCHITTEST message:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  StdCtrls;

type
  TForm1 = class(TForm)
  private
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  inherited;
  if Message.Result = HTCAPTION
  then Message.Result := HTCLIENT;
end;

end.

--
Martin

Other Threads