whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

46 Visitors Online


 
...use EnumFontFamilies?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (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;


 

Rate this tip:

poor
very good


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