RAD Studio VCL Reference
|
Creates an instance of TControl.
constructor Create(AOwner: TComponent); override;
virtual __fastcall TControl(TComponent * AOwner);
Calling Create constructs and initializes an instance of TControl. However, you should never attempt to instantiate a TControl. This class is intended solely as a base class from which other control classes descend and you should only call Create to instantiate one of these descendants.
Create calls the parent constructor and initializes the control.
When overriding Create, always call the inherited Create method first, then proceed with the control's initialization. Remember to specify the override directive when overriding the Create method.
Delphi Examples:
{ This examples requires a TPageControl and a TCheckBox. The form OnCreate event handler populates each sheet with an edit control placed somewhere on the client area of the sheet. Unchecking the checkbox will cause the client area (not the tab area) of the Tab Control to become invisible. } procedure TForm1.CheckBox1Click(Sender: TObject); begin PageControl1.ActivePage.Visible := CheckBox1.Checked; end; procedure TForm1.PageControl1Change(Sender: TObject); begin CheckBox1.Checked := PageControl1.ActivePage.Visible; end; procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin for i := 0 to 9 do with TTabSheet.Create(Self) do begin PageControl := PageControl1; Caption := 'TabSheet' + IntToStr(i); with TEdit.Create(Self) do begin Parent := PageControl1.Pages[i]; Left := Random(PageControl1.ActivePage.ClientWidth - Width); Top := Random(PageControl1.ActivePage.ClientHeight - Height); end; end; PageControl1Change(Sender); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|