Formatierte, gedrehte, mehrzeilige Textausgabe

void __fastcall StringGridRotateTextOut(TStringGrid *Grid, int ARow, int ACol, TRect Rect, AnsiString sOutput, AnsiString sFontName, TColor clFontColor, int iFontSize, int iRotation)
{
     Grid->Canvas->Font->Name = sFontName;
     Grid->Canvas->Font->Size = iFontSize;
     Grid->Canvas->Font->Color = clFontColor;

     // neue Schrift für die gedrehte Ausgabe zusammenbauen
     TFont *tf = new TFont();
     TLogFont lf;
     tf->Assign(Grid->Canvas->Font);
     GetObject(tf->Handle, sizeof(lf), &lf);
     lf.lfEscapement = iRotation * 10;
     lf.lfOrientation = 0;
     HFONT hfont = CreateFontIndirect(&lf);
     tf->Handle = hfont;
     Grid->Canvas->Font->Assign(tf);
     delete tf;

     // Zelle malen
     Grid->Canvas->FillRect(Rect);
     // Text ausgeben
     // Beachten: abhängig vom Drehwinkel muss die X- und Y-Koordinate richtig gesetzt werden!
     // bei 90° z.B. Rect.Left + 2, Rect.Bottom - 2
     // DrawText bietet u.A. die Möglichkeit Text mehrzeilig (DT_WORDBREAK) auszugeben
     DrawText(Grid->Canvas->Handle, sOutput.c_str(), -1, &Rect, DT_VCENTER | DT_CENTER | DT_WORDBREAK);

     // Textausgabe könnte anstatt mit DrawText auch mit TextRect erfolgen,
     // es ist hierbei aber keine mehrzeilige Ausgabe möglich
     // Grid->Canvas->TextRect(Rect, Rect.Left + 2, Rect.Top + 2, sOutput);
}

void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State)
{
     TStringGrid *Grid = (TStringGrid *)Sender;
     Grid->Canvas->Font->Color = clBlack;

     if (ACol == 0)
     {
        // 1. Spalte "normal" fett und schwarz zeichnen
        Grid->Canvas->Font->Style = TFontStyles() << fsBold;
        Grid->Canvas->FillRect(Rect);
        DrawText(Grid->Canvas->Handle, Grid->Cells[ACol][ARow].c_str(), -1, &Rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
     }
     else
     {
         // alle anderen Spalten gedreht und verkleinert zeichnen
         Grid->Canvas->Font->Style = TFontStyles() >> fsBold;
         AnsiString sOutput = Grid->Cells[ACol][ARow] + "\n" + "noch eine Zeile :)";
         StringGridRotateTextOut(Grid, ARow, ACol, Rect, sOutput , "Arial", clBlack, 6, -10);
     }
}