再给你一段,就是有点慢。
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.Font.Name := ComboBox1.Items[Index];
ComboBox1.Canvas.TextOut(Rect.Left + 2, Rect.Top, ComboBox1.Items[Index]);
end;
procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
var
tm: TEXTMETRIC;
begin
if Index < 0 then
Exit;
ComboBox1.Canvas.Font.Name := ComboBox1.Items[Index];
ComboBox1.Canvas.Font.Size := 16;
GetTextMetrics(ComboBox1.Canvas.Handle, tm);
Height := tm.tmHeight + tm.tmExternalLeading + 1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items := Screen.Fonts;
ComboBox1.ItemIndex := 0;
ComboBox1.Style := csOwnerDrawVariable;
end;