Move non Wincontrol objects - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Move non Wincontrol objects

porodoroporodoro Posts: 230Member
[b][red]This message was edited by porodoro at 2006-1-1 11:22:9[/red][/b][hr]
[b][red]This message was edited by porodoro at 2006-1-1 11:21:41[/red][/b][hr]
Hi. I've found a great tutorial by zarko about moving
objects at runtime.
Everything works perfect. Except one thing.
I cant move non TwinControl objects(eg Tlabel , Tlistbox etc)!

Is it possible to move non win objects ? if yes how ?

thanks !


http://delphi.about.com/library/weekly/aa102505a.htm




Comments

  • zibadianzibadian Posts: 6,349Member
    : [b][red]This message was edited by porodoro at 2006-1-1 11:22:9[/red][/b][hr]
    : [b][red]This message was edited by porodoro at 2006-1-1 11:21:41[/red][/b][hr]
    : Hi. I've found a great tutorial by zarko about moving
    : objects at runtime.
    : Everything works perfect. Except one thing.
    : I cant move non TwinControl objects(eg Tlabel , Tlistbox etc)!
    :
    : Is it possible to move non win objects ? if yes how ?
    :
    : thanks !
    :
    :
    : http://delphi.about.com/library/weekly/aa102505a.htm
    :
    :
    :
    :
    :
    It is possible. Set the DragMode to dmAutomatic, and implement the form's OnDragOver() and OnDragDrop() like this:
    [code]
    procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
    begin
    if Source is TControl then
    begin
    TControl(Source).Left := x;
    TControl(Source).Top := y;
    end;
    end;

    procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
    State: TDragState; var Accept: Boolean);
    begin
    Accept := Source is TControl;
    end;
    [/code]
    I've tested this code using a TLabel and a TPanel, and could place them anywhere on the form. You can specify, which controls can be moved, with the DragMode.
  • porodoroporodoro Posts: 230Member
    : : [b][red]This message was edited by porodoro at 2006-1-1 11:22:9[/red][/b][hr]
    : : [b][red]This message was edited by porodoro at 2006-1-1 11:21:41[/red][/b][hr]
    : : Hi. I've found a great tutorial by zarko about moving
    : : objects at runtime.
    : : Everything works perfect. Except one thing.
    : : I cant move non TwinControl objects(eg Tlabel , Tlistbox etc)!
    : :
    : : Is it possible to move non win objects ? if yes how ?
    : :
    : : thanks !
    : :
    : :
    : : http://delphi.about.com/library/weekly/aa102505a.htm
    : :
    : :
    : :
    : :
    : :
    : It is possible. Set the DragMode to dmAutomatic, and implement the form's OnDragOver() and OnDragDrop() like this:
    : [code]
    : procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
    : begin
    : if Source is TControl then
    : begin
    : TControl(Source).Left := x;
    : TControl(Source).Top := y;
    : end;
    : end;
    :
    : procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
    : State: TDragState; var Accept: Boolean);
    : begin
    : Accept := Source is TControl;
    : end;
    : [/code]
    : I've tested this code using a TLabel and a TPanel, and could place them anywhere on the form. You can specify, which controls can be moved, with the DragMode.
    :
    Yeah it worked!.
    thanks (again),.
Sign In or Register to comment.