Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Pintar en un TListBox o TCheckListBox (https://www.clubdelphi.com/foros/showthread.php?t=80516)

dec 29-06-2006 23:21:49

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;


La franja horaria es GMT +2. Ahora son las 01:24:04.

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