Hi,
I have a multiple Dynamic Form2's attached to Form1 Pagecontrol tabsheets.
I want to do things on the Form2s based on a button click from Form1. Any sugestions?
==============================
Form1 has:
Button1
Button2
PageControl1
procedure TForm1.Button1Click(Sender: TObject);
var ts: TTabSheet;
begin
ts := TTabSheet.Create(Self);
With ts Do
Begin
Caption := 'Test';
PageControl := PageControl1;
With TForm2.Create( Self ) Do
Begin
Parent := ts;
Visible := True;
Align := alClient;
Windows.SetParent( handle, ts.handle );
End;
End;
Pagecontrol1.ActivePage := ts;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PageControl1.OwnerDraw:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin
for i := 0 to pagecontrol1.PageCount - 1 do
begin
pagecontrol1.ActivePageIndex := i;
Form2.lOutput.Caption := IntToStr(PageControl1.ActivePageIndex);
// The above line doesn't error but doesn't do anything
// Do something on Form2
// e.g. run the TForm2.Button1Click
// for each sheet
end;
end;
====================================
Form2 has:
lOutput: TLabel;
Button1: TButton;
procedure TForm2.Button1Click(Sender: TObject);
begin
lOutput.Caption := IntToStr(Form1.PageControl1.ActivePageIndex);
end;
===================================
I have a multiple Dynamic Form2's attached to Form1 Pagecontrol tabsheets.
I want to do things on the Form2s based on a button click from Form1. Any sugestions?
==============================
Form1 has:
Button1
Button2
PageControl1
procedure TForm1.Button1Click(Sender: TObject);
var ts: TTabSheet;
begin
ts := TTabSheet.Create(Self);
With ts Do
Begin
Caption := 'Test';
PageControl := PageControl1;
With TForm2.Create( Self ) Do
Begin
Parent := ts;
Visible := True;
Align := alClient;
Windows.SetParent( handle, ts.handle );
End;
End;
Pagecontrol1.ActivePage := ts;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PageControl1.OwnerDraw:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin
for i := 0 to pagecontrol1.PageCount - 1 do
begin
pagecontrol1.ActivePageIndex := i;
Form2.lOutput.Caption := IntToStr(PageControl1.ActivePageIndex);
// The above line doesn't error but doesn't do anything
// Do something on Form2
// e.g. run the TForm2.Button1Click
// for each sheet
end;
end;
====================================
Form2 has:
lOutput: TLabel;
Button1: TButton;
procedure TForm2.Button1Click(Sender: TObject);
begin
lOutput.Caption := IntToStr(Form1.PageControl1.ActivePageIndex);
end;
===================================