Ver Mensaje Individual
  #1  
Antiguo 30-06-2006
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Pintar en un TListBox o TCheckListBox

Ejemplo 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