unit PageControlPages;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    TabSheet4: TTabSheet;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: PageControlPages
// Property: ComCtrls.TPageControl.Pages
// Method: ComCtrls.TCustomTabControl.TabHeight
// Property: ComCtrls.TCustomTabControl.TabWidth
// Property: Graphics.TCanvas.TextHeight
// Property: Graphics.TCanvas.TextWidth

// BeginCode
{
This project requires a TPageControl and several TTabPages.
To add new pages, right-click the TPageControl and select 
New Page.  During the form creation the width and height of 
all tabs on the Page Control becomes double the largest 
previous value. So if there are three tabs with captions that
are 12, 23, and 19 characters long, the TabWidth would be the
number of pixels required to fit 46 characters.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  with PageControl1 do
  begin
    for i := 0 to PageCount - 1 do
    begin
      if (Canvas.TextWidth(Pages[i].Caption) * 2) > TabWidth then
        TabWidth := Canvas.TextWidth(Pages[i].Caption) * 2;
      if (Canvas.TextHeight(Pages[i].Caption) * 2) > TabHeight then
        TabHeight := Canvas.TextHeight(Pages[i].Caption) * 2;
    end;
  end;
end;
// EndCode
// EndExample: PageControlPages
end.
