Ver Mensaje Individual
  #2  
Antiguo 21-04-2015
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
Hola elrayo76.

Si, es posible.
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
begin
  //...
  Listbox1.Style := lbOwnerDrawVariable;  
end;

procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
var
  cv: TCanvas;
  H : HWND;
  R : TRect;
begin
  cv := TCanvas.Create;
  try
    cv.Handle := GetDeviceContext(H);
    R  := ListBox1.ClientRect;
    Height := DrawText(cv.Handle,PChar(ListBox1.Items[Index]), -1, R, DT_WORDBREAK);
  finally
    cv.Free;
  end;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  cv: TCanvas;
begin
  cv:= Listbox1.Canvas;
  cv.FillRect(Rect);
  DrawText(cv.Handle, PChar(ListBox1.Items[Index]), -1, Rect, DT_LEFT+DT_TOP+DT_WORDBREAK);
  Invalidate;
end;

Salida:


Saludos
__________________
Daniel Didriksen

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

Última edición por ecfisa fecha: 21-04-2015 a las 19:09:03. Razón: agregar imágen
Responder Con Cita