2007. december 8., szombat

How to make a form non-moveable


Problem/Question/Abstract:

How to make a form non-moveable

Answer:

It is easy to make a form non-moveable.
Choose a borderstyle like bsDialog so that the window can not be resized.

Then add an handler for the WM_WINDOWPOSCHANGING message and override the change.


type
  TMyForm = class(TForm)
  protected
    procedure OnPosChange(var Msg: TWmWindowPosChanging); message
      WM_WINDOWPOSCHANGING;
  end;

procedure TForm1.OnPosChange(var Msg: TWmWindowPosChanging);
begin
  Msg.WindowPos.x := Left;
  Msg.WindowPos.y := Top;
  Msg.Result := 0;
end;

Nincsenek megjegyzések:

Megjegyzés küldése