장성호님 고마워효 ^o^
장성호 님이 쓰신 글 :
: 생성자에서 몇가지 실수가 있네요
:
: 1. 새로만은 생성자에서 상위 생성자를 호출해줘야 합니다.
:
:
: constructor TForm1.Create(Owner: TComponent; str: string);
: begin
: //이렇게...
: inherited Create(Owner);
: end;
:
:
: 2. 그리고 TForm2.Caption := i ; 여기서
: TForm2는 클래스입니다 객체가 아닙니다.
: 새로 생성된 폼 자신의 propery에 접근하려면 그냥 쓰거나 아님 self 키워드로 하셔야...
:
: constructor TForm1.Create(Owner: TComponent; str: string);
: begin
: inherited Create(Owner);
:
: self.Caption:=str; //이렇게 하거나
: Caption:=str; //이렇게 하거나..
: end;
:
:
:
:
: 이상입니다.
:
:
:
: 레드폭스 님이 쓰신 글 :
: : Showmessage 박스가 좀 그래서.. 따로 폼을 만들어서 띄울려고 하거든요.
: :
: : 그래서 폼을 Create해서 띄울때 생성자를만들어서 몬가 변수를 넣어서 띄우게 하고 싶거든요..
: :
: : 좀 찾아봤는데 잘 안되서..
: :
: :
: : * 요기가 폼 띄우는 버튼
: : FF:= TForm2.Create(self, 'abc');
: : FF.Show;
: :
: :
: :
: : * 요기가 띄워지는 폼
: :
: : unit Unit2;
: :
: : interface
: :
: : uses
: : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
: : Dialogs;
: :
: : type
: : TForm2= class(TForm)
: : private
: : { Private declarations }
: : public
: : { Public declarations }
: : Constructor Create( Owner : TComponent; i : string);
: : end;
: :
: : var
: : Form2: TForm2;
: :
: : implementation
: :
: : {$R *.dfm}
: :
: : Constructor TForm_TForm2.Create( Owner : TComponent; i : string);
: : begin
: : TForm2.Caption := i ;
: : end;
: :
: : end.
: :
: :
: : 이렇게 여기까지 하는데.. 생성이 안됩니다.. override? 를 해야하나요? 가르쳐주세요..