Ver Mensaje Individual
  #5  
Antiguo 30-08-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
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]; // Numero de dias en el mes
  ShortDateFormat := 'dd/mm/yyyy';
  iDay := DayOfTheWeek(StrToDate(Fecha)); // En que dia de la semana estamos (1-7)

  If iDay = 7 Then // Si el primer dia de mes es domingo
    StringGrid1.RowCount := 7
  else
    StringGrid1.RowCount := 6;
  If  iDay = 6  Then // Si el primer dia de mes es domingo
    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;
  // Cargo los días 10 y 15 en ListaFechas para la prueba 
  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 // Los domingos los pintamos en rojo
    Begin
     Canvas.font.Color := clRed;
     Canvas.Font.Style := [fsBold];
    End;
    if gdFixed in State then // Fila superior Dias de la semana en azul
    begin
     Canvas.Brush.Color := clNavy;
     Canvas.Font.Color := clWhite;
     Canvas.Font.Style := [fsBold];
    end;
    { Desactivado (Pinta celda [0,1])
    if gdSelected in State then  // Celda seleccionada
     begin
       Canvas.Brush.Color := clRed;
       Canvas.Font.Color := clHighlightText;
       Canvas.Font.Style := [];
     end;
    }
   {************* Aqui marco los dias especiales ********}
    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.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 30-08-2011 a las 13:25:33. Razón: Corregir Identación
Responder Con Cita