Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.