Einzelnen Beitrag anzeigen

Benutzerbild von dataspider
dataspider

Registriert seit: 9. Nov 2003
Ort: 04539 Groitzsch
1.350 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: TForm in TabSheet laden

  Alt 30. Nov 2012, 09:03
Hi,

falls es etwas nützt, mal ein einfaches Code Schnipsel aus einem Altprojekt:

Delphi-Quellcode:
function ShowForm(AFormClass: TFormClass; AOwner: TComponent; AParent:
    TWinControl = nil; AImageIndex: Integer = -1): TForm;
Var
  APageControl: TcxPageControl;
begin
  Result := AFormClass.Create(AOwner);
  if AParent <> nil then
  begin
    if AParent is TcxPageControl then
    begin
      APageControl := (AParent as TcxPageControl);
      Result.ManualDock(AParent, nil, alClient);
      APageControl.ActivePageIndex := APageControl.PageCount - 1;
      if (AImageIndex > -1) then
        APageControl.ActivePage.ImageIndex := AImageIndex;
      Result.Visible := True;
    end
    else
    begin
      Result.BorderStyle := bsNone;
      Result.Align := alClient;
      Result.Parent := AParent;
    end;
  end;
  Result.Show;
end;
Form erzeugen mit

  ShowForm(TDemo_Form, PCForm); und wie Sir Rufo schon erwähnt: Action := caFree; im OnClose des Formulares...

Frank
Frank Reim
  Mit Zitat antworten Zitat