was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

24 Visitors Online


 
...EnumFontFamilies verwenden?
Autor: P. Below
Homepage: http://www.teamb.com
[ Tip ausdrucken ]  

Tip Bewertung (7):  
     




{
  Example for the use of EnumFontFamilies. This example requires two
  listboxes on a form.

  Beispiel für die Verwendung vo EnumFontFamilies. Das Beispiel benötigt
  2 Listboxen auf der Form.
}


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

function EnumProc(var elf: TEnumLogFont;
  var ntm: TNewTextmetric;
  FontType: Integer;
  listbox: TListbox): Integer; stdcall;
var
  
S: string;
begin
  if 
fonttype = TRUETYPE_FONTTYPE then
  begin
    
listbox.Items.Add(Format('Name: %s', [elf.elfFullName]));
    listbox.Items.Add(Format('Style: %s', [elf.elfStyle]));
  end
  else
    
listbox.Items.Add(Format('Name: %s', [elf.elfLogfont.lfFacename]));
  listbox.Items.Add(Format('Size: %d', [elf.elfLogFont.lfHeight]));
  listbox.Items.Add(Format('Weight: %d', [elf.elfLogFont.lfWeight]));
  if elf.elfLogFont.lfItalic <> 0 then
    
listbox.Items.Add('This font is italic');
  case FontType of
    
DEVICE_FONTTYPE: S   := 'device font';
    RASTER_FONTTYPE: S   := 'raster font';
    TRUETYPE_FONTTYPE: S := 'truetype font'
      else
        
S := 'unknown font type';
  end;
  listbox.Items.Add(Format('This is a %s', [S]));
  Result := 1;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  
listbox2.Clear;
  with listbox1 do
    if 
ItemIndex >= 0 then
      
EnumFontFamilies(Self.Canvas.Handle, PChar(Items[ItemIndex]),
        @EnumProc, Longint(Listbox2));
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners