Autor Beitrag
adler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 511

Windows XP
Delphi 05 Pers
BeitragVerfasst: Sa 18.10.03 18:58 
Hi!

ich möchte wissen, wie man alle auf dem eigenen rechner installierte schriftarten in einer combobox auflisten kann.
danke!

_________________
Wo's nix zu gucken gibt, gibts vielleicht was zu hören.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 18.10.03 19:47 
Hi!

Das geht so:

ausblenden Delphi-Quelltext
1:
ComboBox1.Items := Screen.Fonts;					
adler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 511

Windows XP
Delphi 05 Pers
BeitragVerfasst: Sa 18.10.03 21:00 
Titel: so einfach...
geil,
in visual basic, musste man da so nen rießen schwanz machen...
also, delphi ist ja schon geil!
aber bis man das erstmal kann *g*

_________________
Wo's nix zu gucken gibt, gibts vielleicht was zu hören.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 18.10.03 21:05 
Naja, in Delphi kannst du es auch kompliziert machen - mit API Funktionen (EnumFontFamilies - siehe Code unten) - Aber zum Glück ist schon vieles gekapselt.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function EnumFontClBack(var lp: TEnumLogFont;
  var tm: TNewTextMetric;
  dwType: DWORD;
  lpData: lParam): Integer; stdcall;
begin
  Result := 1;
  with TForm1(lpData), Combobox1 do
  begin
    Items.Add(lp.elfLogFont.lfFaceName);
  end;
end;

EnumFontFamilies(Canvas.Handle, nil, @EnumFontClBack, Integer(Self));
adler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 511

Windows XP
Delphi 05 Pers
BeitragVerfasst: Sa 18.10.03 21:17 
Titel: und wenn...
... ich noch 'Keine' davor machen will?
also, Beispiel:
ausblenden Delphi-Quelltext
1:
schrift_art.Items := 'Keine' + Screen.Fonts;					

Das geht ja nicht. Muss ich das dann wie unten, kompliziert machen? also zB.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function EnumFontClBack(var lp: TEnumLogFont; 
  var tm: TNewTextMetric; 
  dwType: DWORD; 
  lpData: lParam): Integer; stdcall; 
begin 
  Result := 1; 
  with TForm1(lpData), Combobox1 do 
  begin
    schrift_art.Items.Add('Keine');
    Items.Add(lp.elfLogFont.lfFaceName); 
  end; 
end; 

EnumFontFamilies(Canvas.Handle, nil, @EnumFontClBack, Integer(Self));

oder wie kann ich dies realisieren?

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
Wo's nix zu gucken gibt, gibts vielleicht was zu hören.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 18.10.03 21:29 
Wo genau möchtest du 'Keine' hinschreiben?
Vor jede Schrift, nur am Anfang der ListBox?
adler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 511

Windows XP
Delphi 05 Pers
BeitragVerfasst: Sa 18.10.03 23:04 
Titel: nur am anfang
Nur am Anfang der ganzen einträge

_________________
Wo's nix zu gucken gibt, gibts vielleicht was zu hören.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 18.10.03 23:20 
so:

ausblenden Delphi-Quelltext
1:
2:
  ComboBox1.Items := Screen.Fonts;
  ComboBox1.Items.Insert(0, 'Keine');
adler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 511

Windows XP
Delphi 05 Pers
BeitragVerfasst: So 19.10.03 12:14 
OK!

Perfect!

_________________
Wo's nix zu gucken gibt, gibts vielleicht was zu hören.