Ver Mensaje Individual
  #1  
Antiguo 30-06-2006
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - Espańa
Posts: 18.281
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Pintar en un TListBox o TCheckListBox

El ejemplo es sobre el TCheckListBox, ya que creo que es mas complejo y se puede aplicar al TListBox con una pequeńa modificacion poniendo la propiedad Style en lbOwnerDrawFixed y creando el siguiente Evento:

Código Delphi [-]
procedure TForm1.CheckListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
  ABitmap: TBitmap;
begin

  ABitmap := TBitmap.Create;
  try
    ImageList1.GetBitmap( Index, ABitmap );
  finally
    CheckListBox1.Canvas.FillRect(Rect);
    CheckListBox1.Canvas.Draw( 15, Rect.Top, ABitmap );
    CheckListBox1.Canvas.TextOut( ABitmap.Width+20, Rect.Top
    +( ( Rect.Bottom-Rect.Top
    -CheckListBox1.Canvas.TextHeight( CheckListBox1.Items[ Index ] ) ) div 2 )
    , CheckListBox1.Items[ Index ] );
  end;

end;
Responder Con Cita