TTabSheetPageControl (C++)

From RAD Studio Code Examples
Jump to: navigation, search


This example dynamically creates a Page Control, then a series of Tab Sheets on the Page Control.


#include <Comctrls.hpp>
TPageControl* ppc;
const int MAXTABS = 3;
TTabSheet* pts[MAXTABS];
const wchar_t * ppcTabTitles[] = {
  L"ShortString", L"ૐ૧૪Orders", L"ૐ૧૪Items", L"Parts" };
int iTabTitles = sizeof(ppcTabTitles)/sizeof(ppcTabTitles[0]);
const TColor colorPalette[12] = {  // only effective if themes are disabled
  clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia,
  clTeal, clNavy, clMaroon, clLime, clOlive, clPurple};

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
	ppc = new TPageControl(this); // The owner (this) will clean this up.
	ppc->Parent = this;
	ppc->Align = alClient;
	for (int i=0;i<iTabTitles;i++)
		pts[i] = new TTabSheet(this); // The owner (this) will clean this up.
		pts[i]->PageControl = ppc;
		pts[i]->Name = String(L"pts") + ppcTabTitles[i];
		pts[i]->Caption = ppcTabTitles[i];
		pts[i]->Brush->Color = colorPalette[i];