Mirror

Move components on a form during runtime (Views: 26)


Problem/Question/Abstract:

Move components on a form during runtime

Answer:

Moves misc. components on a form, e.g. TButton, TLabel, etc. Put the call in the components OnMouseDown-Eventhandler;
  
Example: MoveObject(Sender, X, Y);

uses
  Windows, Messages;

procedure MoveObject(Sender: TObject; X, Y: Integer);
const
  SC_DragMove = $F012;
begin
  ReleaseCapture;
  (Sender as TControl).Perform(WM_SysCommand, SC_DragMove, 0);
end;

<< Back to main page