Ver Mensaje Individual
  #4  
Antiguo 05-12-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por bulc Ver Mensaje
El problema es que en el Canvas del ListBox no quedan bien alineados Imagen-Texto. Las imágenes se agolpan unas sobre otras.
Hola bulc.

O estoy entendiendo mal tu problema, o la solución es ajustar la propiedad ItemHeight del ListBox a la altura de las imágenes al inicio:
Código Delphi [-]
  ListBox1.ItemHeight := ImageList1.Height;

Por ejemplo:
Código Delphi [-]
...
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  with ListBox1 do
  begin
    Columns:= 1;
    Style:= lbOwnerDrawFixed;
    for i:= 0 to 9 do
      Items.Add('Item '+IntToStr(i));
    Font.Size := 24;  // tamaño font a gusto
    ItemHeight:= ImageList1.Height; // en el ejemplo: 48x48
  end;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with TListBox(Control) do
  begin
    Canvas.FillRect(Rect);
    ImageList1.Draw(Canvas,  Rect.Left,  Rect.Top, Index);
    Canvas.TextOut(Rect.Left + ImageList1.Width + 10,
      ((Rect.Top+Rect.Bottom)div 2)-(Font.Size div 2), Items[Index]);
  end;
end;
...
Da este resultado:



Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita