Welcome, Guest
Username: Password: Remember me
General Purpose Components and Libraries, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

TFZPageControl: how to add a page at runtime? 9 years 6 months ago #6383

  • Matteo Riso
  • Matteo Riso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • ZipGenius developer
  • Posts: 17
  • Thank you received: 0
Hello.
I'm pretty new to CodeTyphon and I'm loving it day after day.
I'm having some trouble with the TFZPageControl.
I would like to add a page at runtime but it seems I can't figure out how to achieve that result.

Thanks for such a wonderful IDE!
ZipGenius - the free file compression suite for Windows (and Linux soon).

Please Log in or Create an account to join the conversation.

TFZPageControl: how to add a page at runtime? 9 years 6 months ago #6384

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4504
  • Thank you received: 1100
Thanks Sir
Have fun..

For run time my suggestion :
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, FZCommon, FZBase, Forms, Controls, Graphics,
  Dialogs;
type
  { TForm1 }
  TForm1 = class(TForm)
    FZButton1: TFZButton;
    FZPageControl1: TFZPageControl;
    procedure FZButton1Click(Sender: TObject);
  private
    FZPageControl1Pg1: TFZVirtualPage;
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.FZButton1Click(Sender: TObject);
begin
 FZPageControl1Pg1:= TFZVirtualPage.Create(FZPageControl1);  //<=== this is  Mandatory
 FZPageControl1Pg1.Parent:=FZPageControl1;      //<===  this is  Mandatory

 with FZPageControl1Pg1 do    //<===  this is  optional
 begin
      Left := 0;
      Height := 178;
      Top := 22 ;
      Width := 240 ;
      Appearance.Border.Normal.Color := clSilver ;
      Appearance.Border.Normal.Width := 1   ;
      Appearance.Border.Normal.Option := [mboTop, mboBottom]   ;
      Appearance.Border.Normal.Visible := True   ;
      Appearance.Border.Hover.Color := clBlack;
      Appearance.Border.Hover.Width := 0 ;
      Appearance.Border.Hover.Option := [mboTop, mboLeft, mboBottom, mboRight]  ;
      Appearance.Border.Hover.Visible := True  ;
      Appearance.Border.HotTrack := False ;
      Appearance.Color.Normal := clDefault ;
      Appearance.Color.Hover := clDefault;
      Appearance.Color.HotTrack := False ;
      Appearance.Font.HotTrack := False ;
      Align := alClient ;
      Visible := False ;
      TabOrder := 1   ;
      Caption := 'PAGE1';
 end;

end;

end.
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: Matteo Riso

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

TFZPageControl: how to add a page at runtime? 9 years 6 months ago #6385

  • medios
  • medios's Avatar
  • Visitor
  • Visitor
///////////////////////////////////////////////////////////////////
// //
// Procedure qui ajoute une nouvelle page dans tpagecontrol //
// Maj le 07/10/2014 At 21:33 //
///////////////////////////////////////////////////////////////////
procedure TAcceuil.ButtonAddPage(Sender: TObject);
var NewTab : TTabSheet; //Déclaration du nouveau Tab
begin
NewTab := TTabSheet.Create(PageAcceuil) ;
NewTab.PageControl := PageAcceuil;

NewTab.Caption := 'Nouvelle page';
NewTab.Caption:=InputBox('Ajout nouvelle page','Donner un nom de page', 'Nouvelle page');
PageAcceuil.ActivePage := NewTab;
end;



///////////////////////////////////////////////////////////////////
// //
// Procedure qui control le click sur la croix close du TabSheet //
// Maj le 07/10/2014 //
///////////////////////////////////////////////////////////////////
procedure TAcceuil.PageAcceuilCloseTabClicked(Sender: TObject);
var
vTabsheet : TTabSheet;
vPage : integer;
begin
vTabsheet := Sender as TTabsheet;
vPage := vTabsheet.PageIndex;

//Empécher la fermeture de l'anglet principal (TabAcceuil)
IF vTabsheet.PageIndex = 0 then
begin
ShowMessage('Fermeture non autorisé');
Exit ;
end;

//On ferme le TabSheet
PageAcceuil.Page[vPage].Controls[0].Free;
PageAcceuil.Page[vPage].Destroy;
end;

Please Log in or Create an account to join the conversation.

TFZPageControl: how to add a page at runtime? 9 years 6 months ago #6386

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4504
  • Thank you received: 1100
Thanks Sir
can you attach (zip first) a simple sample for CodeOcean ?
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

TFZPageControl: how to add a page at runtime? 9 years 6 months ago #6387

  • Matteo Riso
  • Matteo Riso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • ZipGenius developer
  • Posts: 17
  • Thank you received: 0
Dear Sternas, your solutions was right but I had to customize it a little bit.
In fact, while the first two mandatory lines of your sample have helped me adding a new tab, that tab looked a bit malformed: no styling, no caption, TFZPageControl menu not visible... (attachment #1)

I had to dig a bit and found a good solution in "allfzregister.pas", where the code creates the extension for the properties editor where you can add pages at design time. In fact that creates good looking tabs and it helped me to find out how to add a page at runtime without messing up the layout. (attachment #2)

Here is my actual code:
procedure TMainForm.ToolButton2Click(Sender: TObject);
var
   myTab: TFZVirtualPage;
begin
     myTab:=TFZVirtualPage.Create(pagecontrol1.Owner ); // specifying ".Owner" is MANDATORY.
     mytab.Caption :='aaaa';  // Don't know why but this line gets ignored....
     mytab.Align := alClient;
     myTab.parent:=pagecontrol1;
     mytab.Caption :='PAGE '+inttostr(pagecontrol1.PageCount); // and only this caption will be shown.
end;
ZipGenius - the free file compression suite for Windows (and Linux soon).

Please Log in or Create an account to join the conversation.

Last edit: by Matteo Riso.
  • Page:
  • 1