1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| function EnumFontClBackEx(var lp: TEnumLogFontEx;
var tm: TNewTextMetricEx;
dwType: LongInt;//DWORD;
lpData: lParam): Integer; stdcall;
begin
with TForm1(lpData), Combobox1 do
Items.Add(lp.elfLogFont.lfFaceName);
Result := 1;
end;
procedure TForm1.FormShow(Sender: TObject);
var
DC: THandle;
LogFont: TLogFont;
begin
// /!\ il FAUT ces 3 lignes sinon liste vide /!\
LogFont.lfFaceName := '';
LogFont.lfCharSet := DEFAULT_CHARSET;
LogFont.lfPitchAndFamily := 0;
//lfPitchAndFamily -- Must be set to zero for all language versions of the operating system.
// trouvé ce commentaire un jour qqpart, il me suit de code en code,
// de prog en prog, il faudrait faire des tests plus poussés...
DC := GetDC(0);
if DC <> 0 then begin
//EnumFontFamilies(Canvas.Handle, nil, @EnumFontClBack, Integer(Self));
//EnumFontFamilies(DC, nil, @EnumFontClBack, Integer(Self));
// Combobox vide si pas "Ex" et LogFont -- dessus ok sous D7, dessous ok sous Linux pas testé sous D7
EnumFontFamiliesEx(DC, @LogFont, @EnumFontClBackEx, Integer(Self), 0);
ReleaseDC(0, DC)
end;
end; |
Partager