/*
HeaderSection, OnDrawSection, Sections, Canvas, TextOut example
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  THeaderSection!AL(`theadersection_object',1,`TopicNotFound',`main') *pSection;
  for (int i = 0; i <= 4; i++)
  {
    pSection = HeaderControl1->Sections->Add();
    pSection->Text = "Section " + IntToStr(i);
    pSection->MinWidth = pSection->Text.Length * HeaderControl1->Font->Size;
    // Owner draw every other section
    if (i % 2 == 0)
      pSection->Style = hsOwnerDraw;
    else
      pSection->Style = hsText;
  }
}
void __fastcall TForm1::HeaderControl1DrawSection(THeaderControl *HeaderControl, THeaderSection *Section, const TRect &Rect, bool Pressed)
{
  if (Pressed)
    HeaderControl->Canvas->Font->Color = clRed;
  else
    HeaderControl->Canvas->Font->Color = clBlue;
  HeaderControl->Canvas->TextOut(Rect.Left + HeaderControl->Canvas->Font->Size, Rect.Top + 2, "Custom " + IntToStr(Section->Index));
}
 
