Hi all, I created this general procedure to free and assign a forms' panel to a main unit's panel. Doing this my "old" way works fine, as follows:
// Freeing any old panel from the Main panel
case CurrentTab of
tab1 : begin
formOne.pnOne := nil;
formOne.free;
end;
tab2 : begin
formTwo.pnTwo := nil;
formTwo.free;
end;
end;{case freeing panel and form}
// Load panel from other unit on Main panel
case NewTab of
tab1 : begin
application.createForm(TformOne, formOne);
formOne.pnOne.parent := pnMain;
end;
tab2 : begin
application.createForm(TformTwo, formTwo);
formTwo.pnTwo.parent := pnMain;
end;
end;{case load panel from form}
So this old method works fine.
Now I created these two procedures to do the same thing:
procedure FreePanel(fForm : TForm; pnPanel : TPanel);
begin
pnPanel.parent := nil;
fForm.free;
end;{FreePanel}
procedure LoadPanel(vtFormClass: TFormClass; fForm : TForm; pnPanel :
TPanel);
begin
application.createForm(vtformClass, fForm);
pnPanel.parent := pnMain;
end;{LoadPanel}
begin
case CurrentTab of
tabOne : FreePanel(formOne, formOne.pnOne);
tabTwo : FreePanel(formTwo, formTwo.pnTwo);
end;
case NewTab of
tabOne : LoadPanel(TformOne, formOne, formOne.pnOne);
tabTwo : LoadPanel(TformTwo, formTwo, formTwo.pnTwo);
end;
But seem to fail on freeing after loading. Any idea why?
TIA
John
<<attachment: winmail.dat>>
