Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

Converting from TNotebook to TPageControl

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

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]
Felipe Monteiro de Carvalho
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
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?

The future of TCustomNotebook is getting renamed to TCustomPageControl, so it will work the same, just the casted named will need to change.

Felipe Monteiro de Carvalho
Mark Morgan Lloyd
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 10 lines
On Sun, Apr 24, 2011 at 2:33 PM, Mark Morgan Lloyd wrote: > 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? The future of TCustomNotebook is getting renamed to TCustomPageControl, so it will work the same, just the casted named will need to change.

Thanks Felipe. Nice to know I'm not doing anything too unorthodox.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]