PageControlPages (C++)

From RAD Studio Code Examples
Jump to: navigation, search


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 become double the largest previous value. So if there are three tabs with captions that are 12, 23, and 19 characters long, the TabWidth is the number of pixels required to fit 46 characters.


__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
  for (int i = 0; i < PageControl1->PageCount; i++)
     String s = PageControl1->Pages[i]->Caption;
     if (Canvas->TextWidth(s) * 2 > PageControl1->TabWidth)
        PageControl1->TabWidth = Canvas->TextWidth(s) * 2;
	  if (Canvas->TextHeight(s) * 2 > PageControl1->TabHeight)
        PageControl1->TabHeight = Canvas->TextHeight(s) * 2;