[Lazarus] Adding and hiding TPageControl tabs

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Sep 26 16:32:45 CEST 2013


I know that this should be an FAQ, but Google isn't being much help.

I've got a TPageControl with a single design-time page, on which there's 
a Synedit which is used (a) as a splash when there's no other tabs and 
(b) as a template for design-time properties.

I can add an extra tab and put a Synedit in it under program control, 
and load it with text. What I can't do is hide the original (index zero) 
tab: if I do, the Synedit vanishes:

procedure TListerD.tntShim;

var     tab: TTabSheet;
         syn: TSynEdit;

begin
   tab := fTntPageControl.AddTabsheet;
   tab.parent := fTntPageControl;     // Is this necessary?
   tab.Caption := 'New';
   syn := TSynEdit.Create(tab);
   tab.InsertControl(syn);
   syn.Parent := tab;                 // Is this necessary?
   syn.Lines.Assign(fTntStrings);

   tab.TabVisible := true;
   fTntPageControl.Pages[0].TabVisible := false; // Trouble
   fTntPageControl.ShowTabs := true;

This is a shim called from Synchronize(), fTntPageControl etc. are used 
as temporary storage. If the penultimate line is commented out then both 
tabs and their contents are visible, but if it's left in then the [0] 
tab is hidden and the newly-created [1] tab has no visible content.

Lazarus 1.0 on x86 Linux. Any polite suggestions appreciated.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list