My Main application form has a Page Control on it with tabs like
"Actions", "Server Data", "Sharenames", "FileLists".
I have data entry forms for all but the "Actions" Tabsheet which uses
various controls created at design time.
What I would like to do is to create and insert the data entry form into
a TabSheet (PageControl) at runtime when that Tab is selected and how to
destroy when a different Tab is selected.
Brooks Vaughn
MailTo:bro...@tidalwave.net
use the pagecontrols OnChanging event to record the tabsheet the user is
changing from:
FLastTabsheet := pagecontrol1.ActivePage;
You cannot destroy the child form for it here since it is still visible,
that would cause flashing.
The main work is done in the pagecontrols OnChange event. The new tabsheet
is already active but not yet visible here.
Case ActivePage.PageIndex Of
0: ;// Action page, no child form for this one
1: Begin
//Server data page
With TServerDataChildform.Create( self ) Do Begin
Parent := ActivePage;
Align := alClient;
Show;
End;
End; // case 1
2: Begin
//Server data page
With TSharenamesChildform.Create( self ) Do Begin
Parent := ActivePage;
Align := alClient;
Show;
End;
End; // case 2
3: .... etc.
end; // Case
If FLastTabsheet.PageIndex <> 0 Then
If FLastTabSheet.ControlCount > 0 Then
FLastTabsheet.Controls[0].Free;
Note that the childforms OnCloseQuery or OnCLose events will not fire this
way, if you need the children to perform some cleanup before they go down
send them a custom message. OnActivate and OnDeacticate will also not fire
for child forms, you can trigger these events by sending CM_ACTIVATE and
CM_DEACTIVATE messages to the child form manually.
Childforms should have a borderstyle of bsNone and no border icons.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!