A: This uses a TabSet to do the "page choosing". First, you must make an array that will hold the form pointers that looks something like this:
FakePage: array[0..2] of TForm;
Then you need these methods:
procedure TForm1.FormShow(Sender: TObject);
var i: integer;
begin
FakePage[0] := TForm2.create(application);
FakePage[1] := TForm3.create(application);
FakePage[2] := TForm4.create(application);
for i := 0 to 2 do begin
FakePage[i].parent := panel1;
FakePage[i].TabOrder := panel1.TabOrder;
with panel1 do
FakePage[i].SetBounds(left + 2, top
+ 2, width - 4, height - 4);
end;
FakePage[TabSet1.TabIndex].show;
end;
procedure TForm1.TabSet1Change(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
begin
FakePage[TabSet1.TabIndex].hide;
FakePage[NewTab].show;
end;
This is the code that we place on the forms :
First, the prototype in the form's declaration:
procedure CreateParams(var params: TCreateParams); override;
Then the custom code:
procedure TForm2.CreateParams(var params: TCreateParams);
begin
inherited CreateParams(params);
with params do begin
WndParent := application.MainForm.handle;
style := ws_child or ws_ClipSiblings;
x := 0;
y := 0;
end;
end;
Here is an example of how to manipulate the form itself:
procedure TForm1.Button1Click(Sender: TObject);
begin
case Tabset1.TabIndex of
0: (FakePage[0] as TForm2).edit1.text := 'This is
for form 2.';
1: (FakePage[1] as TForm3).edit1.text := 'This is
for form 3.';
2: (FakePage[2] as TForm4).edit1.text := 'This is
for form 4.';
end;
end;