Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #9  
Antiguo 30-09-2008
IgnacioHaro IgnacioHaro is offline
Miembro
 
Registrado: oct 2007
Posts: 19
Poder: 0
IgnacioHaro Va por buen camino
Cool solucion

hola, disculpen, aqui esta la forma en q lo hice:

q_curacion es un TZQuery y cada segundo hago un refresh al query con un TTimer.

En esta pantalla voy insertando registros en una BD y le digo en que fecha y hora empieza y en que fecha y hora termina, y durante este tiempo se debera mostrar una barra de progreso representando el procentaje de los minutos transcurridos.

Código Delphi [-]
procedure Tf_telecuracion.dbg_telecuracionDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  fValue,minTotal, minTrans: Integer;
  ActualPenColor, ActualBrushColor: TColor;
  EmptyDS: Boolean;
  DrawRect: TRect;
  fWidth1, fLeft2: Integer;
  StrValue: string;
begin
  // Es la columna de progreso ?
  if not (Column.FieldName = 'progreso') then begin
    Exit;
  end;
  minTotal:= MinutesBetween(q_curacion.FieldByName('inicio').AsDateTime, q_curacion.FieldByName('final').AsDateTime);
  minTrans:= MinutesBetween(q_curacion.FieldByName('inicio').AsDateTime, now);
  fValue:= minTrans * 100 DIV minTotal;
  if fValue > 100 then
     fValue:= 100;
  StrValue := IntToStr(fValue) +  CHAR_PERCENT;
  // Calcular el Rectángulo
  DrawRect := Rect;
  InflateRect(DrawRect, -1, -1);
  fWidth1 := Round((DrawRect.Right - DrawRect.Left) * (fValue / 100));
  // Guardamos el color actual
  ActualPenColor := TDBGrid(Sender).Canvas.Pen.Color;
  ActualBrushColor := TDBGrid(Sender).Canvas.Brush.Color;
  // Definir el color de pintado
  TDBGrid(Sender).Canvas.Pen.Color := clHighlight;
  TDBGrid(Sender).Canvas.Brush.Color := clWhite;
  // Dibuja el recuadro exterior
  TDBGrid(Sender).Canvas.Rectangle(DrawRect);
  // Es diferente de 0 y de -1(null)?
  if (fValue > 0) then begin
    // Dibuja la parte que llevamos completada (porcentage)
    TDBGrid(Sender).Canvas.Pen.Color := clGreen;
    TDBGrid(Sender).Canvas.Brush.Color := clGreen;
    // rectángulo del porcentaje
    DrawRect.Right := DrawRect.Left + fWidth1;
    InflateRect(DrawRect, -1, -1);
    TDBGrid(Sender).Canvas.Rectangle(DrawRect);
  end;
  // porcentaje
  DrawRect := Rect;
  InflateRect(DrawRect, -2, -2);
  TDBGrid(Sender).Canvas.Brush.Style := bsClear;
  fLeft2 := DrawRect.Left + (DrawRect.Right - DrawRect.Left) shr 1 -
            (TDBGrid(Sender).Canvas.TextWidth(StrValue) shr 1);
  // Pintar el texto
  TDBGrid(Sender).Canvas.TextRect(DrawRect, fLeft2,
                                  DrawRect.Top + SPACE_TO_CENTER_CELLTEXT, StrValue);
  // Restaurar
  TDBGrid(Sender).Canvas.Pen.Color := ActualPenColor;
  TDBGrid(Sender).Canvas.Brush.Color := ActualBrushColor;
end;
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
SplashScreen + Progress Bar lKinGl Varios 1 14-04-2008 02:13:15
comparar dentro de un grid lynu Varios 2 24-08-2006 01:13:41
Progress Bar al compactar BD Nbull Varios 5 28-02-2005 10:14:16
Problemas Con Progress Bar UTECYBER OOP 4 08-10-2003 18:31:14
I'm progress Neo Varios 2 19-06-2003 20:01:00


La franja horaria es GMT +2. Ahora son las 05:34:05.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi