Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 24-03-2008
Avatar de MaMu
MaMu MaMu is offline
Miembro
 
Registrado: abr 2006
Ubicación: Argentina
Posts: 863
Poder: 21
MaMu Va por buen camino
Bueno, me voy a autoresponer, porque encontré un artículo interesante "googleando" por otros pagos:

Usando el evento OnDrawColumnCell, se pueden utilizar estas rutinas genéricas para pintar un ProgressBar en cualquier TCanvas (El segundo permite pintar un texto entero,y el primero, además una figura opcional del porcentaje). Esta rutina invierte el color del texto de modo que el texto sea siempre legible:


Código Delphi [-]
procedure PaintProgressBar(Canvas: TCanvas; const Rect: TRect; Progress: 
integer; PaintNumber: boolean = true; BarColor: TColor = clBlue; BackColor: 
TColor = clWhite); overload; 
  procedure PaintProgressBar(Canvas: TCanvas; const Rect: TRect; Progress: 
integer; const Text: string; TextAlign: TAlignment; BarColor: TColor = 
clBlue; BackColor: TColor = clWhite); overload; 


implementation 

procedure SetClipRect(Canvas: TCanvas; R: PRect); 
var 
  Rgn    : HRGN; 
begin 
  if R = nil then 
    SelectClipRgn(Canvas.Handle, 0) 
  else begin 
    With Canvas do begin 
      Rgn:=CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom); 
      try 
        SelectClipRgn(Canvas.Handle, Rgn); 
      finally 
        DeleteObject(Rgn); 
      end; 
    end; 
  end; 
end; 

procedure PaintProgressBar(Canvas: TCanvas; const Rect: TRect; Progress: 
integer; PaintNumber: boolean = true; BarColor: TColor = clBlue; BackColor: 
TColor = clWhite); 
begin 
  if Progress = -1 then 
    PaintProgressBar(Canvas, Rect, Progress, '', taCenter, BarColor, 
BackColor) 
  else begin 
    if PaintNumber then 
      PaintProgressBar(Canvas, Rect, Progress, i2s(Progress)+' %', taCenter, 
BarColor, BackColor) 
    else 
      PaintProgressBar(Canvas, Rect, Progress, '', taCenter, BarColor, 
BackColor); 
  end; 
end; 
procedure PaintProgressBar(Canvas: TCanvas; const Rect: TRect; Progress: 
integer; const Text: string; TextAlign: TAlignment; BarColor: TColor = 
clBlue; BackColor: TColor = clWhite); overload; 
var 
  ARect: TRect; 
  R    : TRect; 
  FLAGS: Word; 
begin 
  FLAGS:=0; 
  with Canvas do begin 
    Case TextAlign of 
      taLeftJustify : FLAGS:=DT_LEFT; 
      taRightJustify: FLAGS:=DT_RIGHT; 
      taCenter      : FLAGS:=DT_CENTER; 
    end; 
    FLAGS:=FLAGS or DT_VCENTER or DT_SINGLELINE; 
    ARect:=Rect; 
    InflateRect(ARect, -2, 0); 
    R:=Rect; 
    if Progress <> -1 then begin 
//    InflateRect(R, -1, -1); 
      R.Right:=Round(Progress*(Rect.Right-Rect.Left)/100); 
      Brush.Color:=BarColor; 
      FillRect(R); 
      if Text <> '' then begin 
        SetClipRect(Canvas, @R); 
        Font.Color:=BackColor; 
        DrawText(Handle, PChar(Text), -1, ARect, FLAGS); 
      end; 
      R.Left:=R.Right+1; 
      R.Right:=Rect.Right-1; 
    end; 
    Brush.Color:=BackColor; 
    if Text <> '' then 
      SetClipRect(Canvas, @R); 
    FillRect(R); 
    if Text <> '' then begin 
      Font.Color:=BarColor; 
      DrawText(Handle, PChar(Text), -1, ARect, FLAGS); 
      SetClipRect(Canvas, nil); 
    end; 
  end; 
end;

Y bueno, voy a ver si interpreto como usar todo esto. Lo postié porque me pareció muy interesamte.

Saludos
__________________
Código Delphi [-]
 
try 
ProgramarMicro(80C52,'Intel',MnHex,True);
except
On Exception do
MicroChip.IsPresent(True);
end;
Responder Con Cita
 



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
Actualizar ProgressBar segun se rellena una StringGrid ó DBGrid jaimeh Varios 8 19-12-2007 13:35:51
Validar celda de DBGrid acalderonr Varios 3 29-06-2007 19:30:05
Como Pintar Solo la Celda y No Toda la Columna de la Celda de un dbGrid?? AGAG4 Varios 11 15-11-2004 20:53:28
Seleccionar una celda de un DBGRID Sandochan Conexión con bases de datos 2 28-05-2003 16:09:37


La franja horaria es GMT +2. Ahora son las 17:26:42.


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