Lo he probado y he tenido que modificarlo un poco ya que mi codigo tambien fue modificado un poco para hacer lo que yo queria realmente. Asi ha quedado pero tiene un problemilla:
Código:
void __fastcall TFormRanking::StringGridRankingDrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
TStringGrid *SG = static_cast<TStringGrid*>((TStringGrid*)(Sender));
String cad = SG->Cells[ACol][ARow];
HDC dc = StringGridRanking->Canvas->Handle;
register int Flags = (ACol == 1 || State.Contains(gdFixed) ? DT_CENTER | DT_VCENTER | DT_SINGLELINE :
DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
cad += (ACol != 1 && ARow > 0 ? " " : "");
if (State.Contains(gdFixed)) {
SG->Canvas->Brush->Color = clBtnFace;
SG->Canvas->Font->Color = clWindowText;
SG->Canvas->FillRect(Rect);
DrawText(dc, cad.c_str(), cad.Length(), &Rect, Flags);
}
else if(State.Contains(gdSelected)) {
SG->Canvas->Brush->Color = clWindow;
SG->Canvas->Font->Color = clWindowText;
SG->Canvas->FillRect(Rect);
HDC dc = StringGridRanking->Canvas->Handle; //No se porque pero si no pongo esta linea no aparece el texto de la celda seleccionada
DrawText(dc, cad.c_str(), cad.Length(), &Rect, Flags );
}
else {
if (ARow % 2 == 0){
SG->Canvas->Brush->Color = clSilver;
SG->Canvas->Font->Color = clWindowText;
}
else {
SG->Canvas->Brush->Color = SG->Color;
SG->Canvas->Font->Color = SG->Font->Color;
}
SG->Canvas->FillRect(Rect);
DrawText(dc, cad.c_str(), cad.Length(), &Rect, Flags );
}
}
Ahi tienes el comentario de que tengo que hacer para que funcione y es algo raro ya que eso mismo se hace al principio pero no se porque tengo que volverlo a hacer.