Alle Controls einer Form mit “Schatten” versehen

// die folgende Funktion zeichnet hinter ein Control einen Schatten
void __fastcall TForm1::shadow(TForm *F, TControl *C, int width, TColor color)
{
    TRect rec;
    TColor old;

    rec = C->BoundsRect;
    rec.Left += width;
    rec.Top += width;
    rec.Bottom += width;
    rec.Right += width;

    old = F->Canvas->Brush->Color;
    F->Canvas->Brush->Color = color;
    F->Canvas->FillRect(rec);

    F->Canvas->Brush->Color = old;
}

void __fastcall TForm1::FormPaint(TObject *Sender)
{
    int iSchattenbreite = 3;
    TColor clSchattenfarbe = clBlack;

    for (int i=0; i<this->ControlCount; i++)
    {
        // im Bsp. bekommen nur TPanels und Buttons einem Schatten verpasst
        // es steht natürlich jedem frei weitere if-Anweisungen hinzuzufügen

        if (this->Controls[i]->ClassName().operator AnsiString() == &quot;TButton&quot;) shadow(this, this->Controls[i], iSchattenbreite, clSchattenfarbe);
        if (this->Controls[i]->ClassName().operator AnsiString() == &quot;TPanel&quot;) shadow(this, this->Controls[i], iSchattenbreite, clSchattenfarbe);
    }
}