community.borland.com

Article #16057: How to click and move components at runtime.

 Technical Information Database

TI1057D.txt   How to click and move components at runtime.
Category   :VCL
Platform    :All
Product    :Delphi  All

Description:
Q:  How can I program a component, such as a TPanel, so that I 
can move it around with a click and drag of the mouse?

A:  This code goes on the OnMouseDown event of the component in 
question (a TPanel in this case):

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
const
  SC_DragMove = $F012;  { a magic number }
begin
  ReleaseCapture;
  panel1.perform(WM_SysCommand, SC_DragMove, 0);
end;



Reference:


7/16/98 4:34:00 PM
 

Last Modified: 01-SEP-99