[Lazarus] Converting from TNotebook to TPageControl

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sun Apr 24 14:33:06 CEST 2011


I'm belatedly fixing a couple of projects that I find refer to TNotebook.

Using TNotebook, one can insert and delete pages on the fly using code like

   WITH Hp495xSpoofForm.Notebook1) DO BEGIN
     Pages.Insert(i, 'Port ' + IntToStr(i + 1));
TPage(Pages.Objects[i]).InsertControl(TFrameSpoofResponder.Create(Hp495xSpoofForm), 
0)
   END;

   Hp495xSpoofForm.Notebook1.Pages.Delete(i);

Is there an "approved" way to do this with TPageControl? I see from the 
online info that one can cast to a TCustomNotebook to access .Pages as a 
TStrings, but is this safe in the long term or will TCustomNotebook go 
the way of TNotebook?

I notice that 
http://lazarus-ccr.sourceforge.net/docs/lcl/comctrls/tpagecontrol.html 
has  property Pages: TTabSheet;  while the comctrls.pas has  property 
Pages[Index: Integer]:  etc. Doesn't help much.

-- 
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