I am creating an application where the main form is basically a menu (in a split view) and a pagecontrol with a "home tab" on it. Based on the menu item selected, a new tabsheet is created with an embedded form on it, where the user can perform numerous actions and data look ups, etc. This is all working great, except I have one problem embedded form, whose FormShow method is being triggered twice when a new tab is created for this form.
To create the problem form, I use:
procedure TMain.actMemberExecute(Sender: TObject);
var
NewTabSheet : TTabSheet;
NewMembForm : TMembForm;
begin
CloseSVMenu;
NewTabSheet := TTabSheet.Create(PageControl1);
NewTabSheet.Visible := true;
NewTabSheet.Caption := 'Member Tab';
NewTabSheet.PageControl := PageControl1;
NewTabSheet.ImageIndex := 18;
NewMembForm := TMembForm.Create(NewTabSheet);
NewMembForm.Parent := NewTabSheet;
NewMembForm.Align := alclient;
NewMembForm.Show;
PageControl1.ActivePage := NewTabSheet;
end;
and a "good" tab/form gets created with
procedure TMain.actPersonExecute(Sender: TObject);
var
NewTabSheet : TTabSheet;
NewPersForm : TPersInfoForm;
begin
CloseSVMenu;
NewTabSheet := TTabSheet.Create(PageControl1);
NewTabSheet.Visible := true;
NewTabSheet.Caption := 'Person';
NewTabSheet.PageControl := PageControl1;
NewTabSheet.ImageIndex := 17;
NewPersForm := TPersInfoForm.Create(NewTabSheet);
NewPersForm.Parent := NewTabSheet;
NewPersForm.Align := alClient;
NewPersForm.Show;
PageControl1.ActivePage := NewTabSheet;
end;
Each of the forms have similar OnShow form events which simply position the form's primary table to the first record ( <tdataset>.First), and then check for some other pre-processing before the user sees the data for that form.
After the problem form completes its first pass through FormShow, the entire screen blinks, and FormShow starts again. The other 8 forms, all based on the same code, don't do this.
Help!
Thanks -- Rick Brodzxinsky