Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi System Fonts in ComboBox einlesen (https://www.delphipraxis.net/60569-system-fonts-combobox-einlesen.html)

K-Asche 9. Jan 2006 14:07


System Fonts in ComboBox einlesen
 
Hi@all,

ich möchte alle auf dem System befindlichen Fonts in eine ComboBox einlesen.
Gibt es eine Methode, welche sich sämtliche Fonts besorgt?

LG, Karsten

dataspider 9. Jan 2006 14:11

Re: System Fonts in ComboBox einlesen
 
Hi,

unit Printers einbinden und über printer.fonts einlesen.

Cu, Frank

Der Jan 9. Jan 2006 14:32

Re: System Fonts in ComboBox einlesen
 
Delphi-Quellcode:
ComboBox1.Items.Assign(Screen.Fonts);
sollte helfen.

K-Asche 9. Jan 2006 14:35

Re: System Fonts in ComboBox einlesen
 
Ok sowiet war ich jetzt auch schon, danke,
habe da aber noch 2 Probleme, einmal wie bekomm ich nun die Schriftnamen in die ComboBox.
Zur Info, bin gerade dabei mir ein eigenes Ctrl zu schreiben.
Delphi-Quellcode:
 FPrinter := TPrinter.Create;
  I := FPrinter.Fonts.Count;
  for A := 0 to I do Begin
    Items.Insert(A, FPrinter.Fonts.Text);
  End;
Wenn ich es so versuche bekomme ich eine Exception : Element hat kein übergeordnetes Fenster.

Zweitens sollen die Schriftarten so dargestellt werden, das man sieht wie sie aussehen, wie in Word halt.
Da ich Delphi Neuling bin steh ich gerade voll auf dem Schlauch :gruebel:
Weiß halt noch nicht wie ich die So darstellen soll.

K-Asche 9. Jan 2006 14:39

Re: System Fonts in ComboBox einlesen
 
Ok Prob Nr. 1 hat sich erledigt einfach CreateWnd überschrieben und dort die Schriften eingefügt.

toms 9. Jan 2006 14:43

Re: System Fonts in ComboBox einlesen
 
Delphi-Quellcode:
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with TComboBox(Control) do
  begin
    Canvas.FillRect(rect);
    Canvas.Font.Style := [fsbold];
    Canvas.Font.Name := Items[Index];
    Canvas.TextOut(rect.Left, rect.Top, Items[Index]);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  { Den ComboBox Style noch im Objekt Inspector auf csOwnerDrawFixed setzen }
  ComboBox1.Items := Screen.Fonts;
end;

K-Asche 9. Jan 2006 15:39

Re: System Fonts in ComboBox einlesen
 
Jau besten Dank, das hat wunderbar funktioniert!

Gibt es Jetzt auch noch die Möglichkeit, wie in Word, ein Icon angezeigt zu bekommen welches die Art der Schrift(TrueType etc); mit auszugeben?


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz