TUpDownOnClick (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a new TPageControl, as is, with no new pages created at design time and a TUpDown control, also from the Win95 page of the component palette. The form OnCreate event handler adds several new TabSheet controls to the Page Control. The UpDown1Click event handler fires when you click the up or down button of the TUpDown control. The SelectNextPage method of the Page Control goes forward the comparison. Button = btNext evaluates asTrue. If Button is not btNext, the previous Tab Page is selected.

Code

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
const
  TColor colorPalette[12] = { // only effective when themes are disabled
	clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia,
	clTeal, clNavy, clMaroon, clLime, clOlive, clPurple};
  for (int i = 0; i < 10; i++)
  {
	TTabSheet *page = new TTabSheet(PageControl1);  // These tabsheets are cleaned up by their owner (PageControl).
	page->PageControl = PageControl1;
	page->Caption = String(L"ૐ૧૪ Page") + IntToStr(i);
	page->Brush->Color = colorPalette[i];
  }
}

void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
  PageControl1->SelectNextPage(Button == btNext);
}

Uses