Ver Mensaje Individual
  #11  
Antiguo 24-11-2008
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 26
maeyanes Va por buen camino
Hola...

Estuve checando con un pequeño programa de ejemplo y es cierto lo que comentas...

Del lado del evento OnMeasureItem, veo que el valor que devuelve lo usa el componente para establecer su alto y si lo desactivo no se dibujan bien los items.

Del lado del evento OnDrawItem, hay que tener en cuenta el valor del parámetro State para dibujar los diferentes estados.

Aquí los eventos que usé para las pruebas:

Código Delphi [-]
procedure TForm1.cbbFontsDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with TComboBox(Control) do
  begin
    if not (odComboBoxEdit in State) then
      Canvas.Font.Size := 15;
    Canvas.Font.Name := Items[Index];
    Canvas.FillRect(Rect);
    Canvas.TextOut(Rect.Left, Rect.Top, Items[index]);
    Canvas.Font.Name := Font.Name;
    Canvas.Font.Size := Font.Size
  end
end;

procedure TForm1.cbbFontsMeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
var
  AHeight: Integer;
  Bitmap: TBitmap;

begin
  if Index < 0 then
    Exit;
  with TComboBox(Control) do
  begin
    Bitmap := TBitmap.Create;
    try
      Bitmap.Canvas.Font.Name := Items[Index];
      Bitmap.Canvas.Font.Size := 15;
      AHeight := Bitmap.Canvas.TextHeight(Items[Index])
    finally
      Bitmap.Free
    end;
  end;
  Height := AHeight
end;


Saludos...
Responder Con Cita