Ver Mensaje Individual
  #3  
Antiguo 30-08-2011
ramonibk ramonibk is offline
Miembro
 
Registrado: may 2004
Posts: 193
Reputación: 20
ramonibk Va por buen camino
Parece que esta no es la solución.

pues al ejecutar me da el error
"list index of bounds 1239256"

Os cuento mas o menos todo el proceso pare que me comentéis.

Tengo un procedimiento llamado calendario que es quie me pinta eso el calendario.
Código Delphi [-]
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
   Begin
    StringGrid1.RowCount := 7;
   End Else
   Begin
    StringGrid1.RowCount := 6;
   End;
  If  iDay = 6  Then // Si el primer dia de mes es domingo
   Begin
     If iNumDays = 31 Then
       Begin
        StringGrid1.RowCount := 7;
       End;
   End Else
   Begin
    StringGrid1.RowCount := 6;
   End;

 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;
end;
Este procedimiento es cargado ne el create del form.
y releído cuando se varia de mes o año y a contibuacion en el OnDrawCell
Código Delphi [-]
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;
  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 ********//
 if ( StringGrid1.Cells[ACol,ARow]= '10' ) And (wMes=8) Then
     begin
       Canvas.Brush.Color := clYellow;
       Canvas.Font.Style := [fsBold];
     end;

 if ( StringGrid1.Cells[ACol,ARow]= '15' ) And (wMes=8) Then
     begin
       Canvas.Brush.Color := clYellow;
       Canvas.Font.Style := [fsBold];
     end;
//***********************************************//
   Canvas.FillRect(Rect);
   Canvas.TextRect(Rect, Rect.Left + (Rect.Right - Rect.Left - Canvas.TextWidth(Cells[ACol,ARow]) + 1)
                                      div 2, Rect.Top + 2, Cells[ACol,ARow]);
  end;
end;
}
y asta aqui todo es correcto, no hay errores y funciona correctamente.
pero cuando intento sustituir.
Código Delphi [-]
//************* Aqui marco los dias especiales ********//
 if ( StringGrid1.Cells[ACol,ARow]= '10' ) And (wMes=8) Then
     begin
       Canvas.Brush.Color := clYellow;
       Canvas.Font.Style := [fsBold];
     end;

 if ( StringGrid1.Cells[ACol,ARow]= '15' ) And (wMes=8) Then
     begin
       Canvas.Brush.Color := clYellow;
       Canvas.Font.Style := [fsBold];
     end;
//***********************************************//
Por
Código Delphi [-]
DecodeDate(StrToDate(ListaFechas.Strings[i]),nAno,nMes,nDia);
 For i := 0 To ListaFechas.Count -1 Do
  Begin
    Canvas.Brush.Color := clYellow;
    Canvas.Font.Style := [fsBold];
    ListBox1.Items.Add(ListaFechas.Strings[i]); //Para verificacion de datos a cargar
  End
he intentado ponerlo por delante de
Código Delphi [-]
with Sender as TStringGrid do
como indica ecfisa en el interior de pero no hay manera y lo único que veo es que el lixbox se vuelve loco
Por cierto también he echo que cuando lo haga de manera automática no lea la primera linea ya que al ser esta las letras de día de la semana es cuelga.
Responder Con Cita