Impedir mover el formulario

2642 vistas

A veces puede ser interesante tener fijo en pantalla un formulario impidiendo que nadie pueda moverlo. Para ello bastará capturando el mensaje WM_WINDOWPOSCHANGING



delphi
  1. type
  2.   TForm1 = class(TForm)
  3.     Button1: TButton;
  4.     Label1: TLabel;
  5.     procedure Button1Click(Sender: TObject);
  6.   private
  7.     procedure NiTeMenees(var m: TWMWINDOWPOSCHANGED); message WM_WINDOWPOSCHANGING ;
  8. ....
  9.  
  10. implementation
  11.  
  12. procedure TForm1.NiTeMenees(var m : TWMWINDOWPOSCHANGED);
  13. begin
  14.   m.windowpos.x := 50;  { Posición x }
  15.   m.windowpos.y := 50;  { Posición y }
  16. end;