Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
copy, paste Posted by adibichea on 20 Feb 2004 at 3:16 PM
if anyone has any ideea how to copy and paste a component (class).
I need copy and paste EASY !!!!!
Report
Re: copy, paste Posted by zibadian on 20 Feb 2004 at 3:48 PM
: if anyone has any ideea how to copy and paste a component (class).
: I need copy and paste EASY !!!!!
:
Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.
Report
Re: copy, paste Posted by adibichea on 20 Feb 2004 at 3:52 PM

: Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.
:
Not that zibadian

dinamically created component!!!
:)))))))))


Report
Re: copy, paste Posted by zibadian on 21 Feb 2004 at 2:08 AM
:
: : Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.
: :
: Not that zibadian
:
: dinamically created component!!!
: :)))))))))
:
:
:
I only answered your question as you asked it.
This might work: Create the new component, and then Assign() the source component to it. That should copy all the necessary properties to the new component.
Report
Re: copy, paste Posted by adibichea on 21 Feb 2004 at 5:03 AM
{
HELP !
F1!
F1!
}
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
btn: array of TButton;
nr_btn: word;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
{Here create a Button}
if nr_btn < 10 then begin
setlength(btn,nr_btn+1);
btn[nr_btn] := TButton.Create(Application);
btn[nr_btn].Left := nr_btn*5;
btn[nr_btn].Top := nr_btn*5;
btn[nr_btn].Caption := '&'+inttostr(nr_btn)+' Btn Created';
btn[nr_btn].Parent := Form1;
btn[nr_btn].Name := 'btn'+inttostr(nr_btn);
inc(nr_btn);
end
else messagedlg('Max nr_btn!',mtInformation,[mbOk],0);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{Here copy a button ????}
if (nr_btn < 10)and(nr_btn<>0) then begin
setlength(btn,nr_btn+1);
btn[nr_btn] := TButton.Create(Application);
btn[nr_btn].Assign(btn[0]); //Here raise an error
{
Error: Cannot assign a TButton to a TButton
How to Copy
}
inc(nr_btn);
end
else messagedlg('Arghhh !',mtError,[mbOk],0);
end;

end.

Report
Re: copy, paste Posted by zibadian on 21 Feb 2004 at 5:47 AM
: {
: HELP !
: F1!
: F1!
: }
: unit Unit1;
:
: interface
:
: uses
: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
: Dialogs, StdCtrls;
:
: type
: TForm1 = class(TForm)
: Button1: TButton;
: Button2: TButton;
: procedure Button1Click(Sender: TObject);
: procedure Button2Click(Sender: TObject);
: private
: { Private declarations }
: public
: { Public declarations }
: end;
:
: var
: Form1: TForm1;
: btn: array of TButton;
: nr_btn: word;
:
: implementation
:
: {$R *.dfm}
:
: procedure TForm1.Button1Click(Sender: TObject);
: begin
: {Here create a Button}
: if nr_btn < 10 then begin
: setlength(btn,nr_btn+1);
: btn[nr_btn] := TButton.Create(Application);
: btn[nr_btn].Left := nr_btn*5;
: btn[nr_btn].Top := nr_btn*5;
: btn[nr_btn].Caption := '&'+inttostr(nr_btn)+' Btn Created';
: btn[nr_btn].Parent := Form1;
: btn[nr_btn].Name := 'btn'+inttostr(nr_btn);
: inc(nr_btn);
: end
: else messagedlg('Max nr_btn!',mtInformation,[mbOk],0);
: end;
:
: procedure TForm1.Button2Click(Sender: TObject);
: begin
: {Here copy a button ????}
: if (nr_btn < 10)and(nr_btn<>0) then begin
: setlength(btn,nr_btn+1);
: btn[nr_btn] := TButton.Create(Application);
: btn[nr_btn].Assign(btn[0]); //Here raise an error
: {
: Error: Cannot assign a TButton to a TButton
: How to Copy
: }
: inc(nr_btn);
: end
: else messagedlg('Arghhh !',mtError,[mbOk],0);
: end;
:
: end.
:
:
You'll have to copy each of the relevant property and event values by hand, which is in your case the Left, Top, Caption and Parent.
Note: each of the component's owner isn't the Application, but the Form on which it is placed. This could be important, when naming the component, since each name must be unique in the owner's list.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.