TControlTop (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses an updown control and a group box on a form, with several controls contained within the group box. When the updown control is clicked, the controls within the group box are moved in the appropriate direction.

Code

void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
  int I;
  TControl *ChildControl;

  for (I = 0; I < GroupBox1->ControlCount; I++)
  {
    ChildControl = GroupBox1->Controls[I];
    if (Button == btNext) 
      ChildControl->Top = ChildControl->Top + 15;
    else
      ChildControl->Top = ChildControl->Top - 15;
  }
}

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  const TColor colorarray[5] = {clYellow, clGreen, clBlue, clLime, clFuchsia};
  GroupBox1->Brush->Color = clRed;
  for (int i = 0; i < GroupBox1->ControlCount; i++)
	dynamic_cast<TWinControl *>(GroupBox1->Controls[i])->Brush->Color = colorarray[i];
}

Uses