Показать сообщение отдельно
  #4  
Старый 23.09.2010, 12:04
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

вот еще с комбиком:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Label1: TLabel;
    ComboBox1: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure ListBox1Click(Sender: TObject);
    procedure ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Items.Assign(Screen.Fonts);
  ComboBox1.Items.Assign(Screen.Fonts);
end;

procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  with ListBox1.Canvas do
  begin
    Font.Name:=ListBox1.Items[Index];
    Font.Size:=0;
    Height:=TextHeight('Wg')+2;
  end;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with ListBox1.Canvas do
  begin
    FillRect(Rect);
    Font.Name:=ListBox1.Items[Index];
    Font.Size:=0;
    TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]);
  end;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  Label1.Caption:=ListBox1.Items[ListBox1.ItemIndex];
end;

procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  if Index=-1 then Exit;
  with ComboBox1.Canvas do
  begin
    Font.Name:=ComboBox1.Items[Index];
    Font.Size:=0;
    Height:=TextHeight('Wg')+2;
  end;
end;

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  if Index=-1 then Exit;
  with ComboBox1.Canvas do
  begin
    FillRect(Rect);
    Font.Name:=ComboBox1.Items[Index];
    Font.Size:=0;
    TextOut(Rect.Left, Rect.Top, ComboBox1.Items[Index]);
  end;
end;

end.
Вложения
Тип файла: rar --.rar (1.8 Кбайт, 7 просмотров)
Ответить с цитированием