TForm with set parent property
Original Reporter info from Mantis: ppiwowar
-
Reporter name: Pawel Piwowar
Original Reporter info from Mantis: ppiwowar
- Reporter name: Pawel Piwowar
Description:
- Create new project, copy this code and run it.
- Press "Start", and...
What's going on after the TForm.Show???
- Try press "Next".
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, Buttons;
type
{ TForm1 }
TForm1 = class(TForm)
private
{ private declarations }
public
{ public declarations }
PCon : TPageControl;
But : TButton;
constructor Create(AOwner: TComponent); override;
procedure ButClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{ TForm1 }
constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
PCon := TPageControl.Create(Self);
PCon.Parent := Self;
PCon.Align := alClient;
But := TButton.Create(Self);
But.Parent := Self;
But.Top := 150;
But.OnClick := @ButClick;
But.Caption := 'Start';
end;
procedure TForm1.ButClick(Sender: TObject);
var
TS : TTabSheet;
form : TForm;
begin
TS := TTabSheet.Create(Self);
TS.Parent := PCon;
TS.Caption := 'Page ' + IntToStr(PCon.PageCount);
form := TForm.Create(Self);
with form do begin
Parent := TS;
BorderStyle := bsNone;
Align := alClient;
with TButton.Create(Self) do begin
Top := 50;
Left := 100;
Parent := form;
end;
Show;
end;
But.Caption := 'Next...';
end;
initialization
{$I Unit1.lrs}
end.
Additional information:
Imported information
--------------------
Name: Pawel Piwowar
Mail: alfapawel (at) tlen.pl
Mantis conversion info:
- Mantis ID: 595
- Target version: 1.4