Mega Code Archive

 
Categories / Delphi / Examples
 

How to make a form non-moveable

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;