Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 16-08-2006
zugazua2001 zugazua2001 is offline
Miembro
 
Registrado: oct 2004
Ubicación: Necochea
Posts: 237
Poder: 22
zugazua2001 Va por buen camino
se puede

Se puede parte de un color y parte de otro¿?
Gracias
Responder Con Cita
  #2  
Antiguo 16-08-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 26
seoane Va por buen camino
Si lo que quieres es pintar en una columna, la mitad de cada celda de un color y la otra mitad de otro, puedes hacer algo así:
Código Delphi [-]
// En el eventon OnDrawCell
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  R: TRect;
begin
  if Sender is TStringGrid then
  begin
    with TStringGrid(Sender), TStringGrid(Sender).Canvas do
    begin
      Canvas.Brush.Style:= bsSolid;
      R:= Rect;
      Canvas.Brush.Color:= clWhite;
      // Pintamos todo el fondo de blanco
      Canvas.FillRect(R);
      // si la columna es la que buscamos, por ejemplo la 3
      if ACol = 3 then
      begin
        R.Right:= (R.Left + R.Right) div 2;
        Canvas.Brush.Color:= clRed;
        // Pintamos la mitad de la celda de rojo
        Canvas.FillRect(R);
      end;
      Canvas.Brush.Style:= bsClear;
      // Escribimos el texto de la celda centradito
      ExtTextOut(Handle,
        (Rect.Left + Rect.Right - TextWidth(Cells[ACol,ARow])) div 2,
        (Rect.Top + Rect.Bottom - TextHeight(Cells[ACol,ARow])) div 2,
        ETO_CLIPPED, @Rect, PChar(Cells[ACol,ARow]),
        Length(Cells[ACol,ARow]),nil);
    end;
  end;
end;

Ahora, si lo que quieres es escribir la mitad de los caracteres de un color y la otra mitad de otro, puedes hacer algo como esto:
Código Delphi [-]
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  x, y: Integer;
  Str1, Str2: String;
begin
  if Sender is TStringGrid then
  begin
    with TStringGrid(Sender), TStringGrid(Sender).Canvas do
    begin
      Canvas.FillRect(Rect);
      Canvas.Brush.Style:= bsClear;
      x:= (Rect.Left + Rect.Right - TextWidth(Cells[ACol,ARow])) div 2;
      y:= (Rect.Top + Rect.Bottom - TextHeight(Cells[ACol,ARow])) div 2;
      Str1:= Copy(Cells[ACol,ARow],1,length(Cells[ACol,ARow]) div 2);
      Str2:= Copy(Cells[ACol,ARow],Length(Str1)+1,length(Cells[ACol,ARow])-Length(Str1));
      Font.Color:= clRed;
      ExtTextOut(Handle,x,y,
        ETO_CLIPPED, @Rect, PChar(Str1),
        Length(Str1),nil);
      x:= x +  TextWidth(Str1);
      Font.Color:= clBlue;
      ExtTextOut(Handle,x,y,
        ETO_CLIPPED, @Rect, PChar(Str2),
        Length(Str1),nil);
    end;
  end;
end;
Responder Con Cita
Respuesta


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
Hacer que una columna de un DbGrid aparezca distinta según valor Aprendiendo OOP 11 30-11-2018 14:47:20
pintar columna DBGRid Coco_jac Varios 1 02-02-2006 23:54:59
Pintar columna de TCalendar Delfino OOP 3 29-01-2005 07:25:43
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
Pintar Celdillas especificas en una grilla josem Conexión con bases de datos 2 19-07-2004 20:57:17


La franja horaria es GMT +2. Ahora son las 06:08:06.


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