Вы можете показывать доступные шрифты WYSIWYG таким способом:
Создайте новый проект, добавьте ListBox и добавьте следующий код:
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items := Screen.Fonts ;
end;
Установите свойство стиля ListBox в lbOwnerDrawVariable и добавьте следующий код в события ListBox OnDrawItem и OnMeasureItem:
procedure TForm1.ListBox1MeasureItem(
Control: TWinControl; Index: Integer;
var Height: Integer);
var
h : integer ;
begin
with Control as TListBox do begin
Canvas.Font.Name := Items[Index] ;
h := Canvas.TextHeight(Items[Index]) ;
end ;
Height := h ;
end;
procedure TForm1.ListBox1DrawItem(
Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with Control as TListBox do begin
Canvas.Font.Name := Items[Index] ;
Canvas.FillRect(Rect) ;
Canvas.TextOut(Rect.Left, Rect.Top, Items[Index]) ;
end ;
end;
В ComboBox, когда свойство Style находится в csOwnerDrawVariable, появляется сообщение Canvas does not allow drawing .
Чтобы избежать этого, установите свойство Style в csOwnerDrawFixed.
По материалам http://delphi3000.com
|