Hola ramonibk.
Primero que nada me alegro que lo hayas solucionado.
Ahora que veo que valor tienen las celdas del StringGrid, la comparación del código que te puse no puede funcionar ya que supuse que las celdas contienian fechas.
Pero adecuando la comparación a celdas con días, funciona igual.
Esta es la prueba rápida que hice sobre tu código:
Código Delphi
[-]
...
uses DateUtils;
var
wMes:Integer= 8;
wAnyo: Integer= 2011;
ListaFechas:TStrings;
Procedure TForm1.Calendario;
var
days : array[0..6] of string;
i, iNumDays, iDay: Integer;
iRowCtr, iColCtr: Integer;
Fecha : String;
begin
Fecha := '1/' + IntToStr(wMes) + '/' + IntToStr(wAnyo);
DaysInMonth( StrToDate( Fecha ));
days[0] := 'L';
days[1] := 'M';
days[2] := 'X';
days[3] := 'J';
days[4] := 'V';
days[5] := 'S';
days[6] := 'D';
with StringGrid1 do
begin
for i := 0 to 6 do
Cells[i, 0] := days[i]
end;
iNumDays := MonthDays[IsLeapYear(WAnyo), WMes]; ShortDateFormat := 'dd/mm/yyyy';
iDay := DayOfTheWeek(StrToDate(Fecha));
If iDay = 7 Then StringGrid1.RowCount := 7
else
StringGrid1.RowCount := 6;
If iDay = 6 Then If iNumDays = 31 Then
StringGrid1.RowCount := 7
else
StringGrid1.RowCount := 6;
iRowCtr := 1;
iColCtr := iDay - 1;
for i := 1 to iNumDays do
begin
StringGrid1.Cells[iColCtr, iRowCtr] := IntToStr(i);
Inc(iColCtr);
if iColCtr > 6 then
begin
iColCtr := 0;
Inc(iRowCtr);
end;
end;
ListaFechas:= TStringList.Create;
ListaFechas.Add('10');
ListaFechas.Add('15');
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Calendario;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
i: Integer;
begin
with Sender as TStringGrid do
begin
if ACol = 6 Then Begin
Canvas.font.Color := clRed;
Canvas.Font.Style := [fsBold];
End;
if gdFixed in State then begin
Canvas.Brush.Color := clNavy;
Canvas.Font.Color := clWhite;
Canvas.Font.Style := [fsBold];
end;
for i:= 0 to ListaFechas.Count-1 do
if (ARow>0) and (wMes = 8) and (Cells[ACol,ARow]>'')and
(StrToInt(Cells[ACol,ARow]) = StrToInt(ListaFechas[i])) then
begin
Canvas.Brush.Color:= clRed;
Canvas.Font.Color:= clWhite;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left,Rect.Top,Cells[ACol,ARow]);
end;
end;
end;
Dado que ya solucionaste el problema, te adjunto la prueba sólo como un comentario.
Un saludo.