[fpc-pascal] Font handles from Win API
Wolfram Kläger
wolfram.klaeger at web.de
Sat Mar 17 02:38:41 CET 2007
Hi everyone,
IŽm too stupid for Windows. Before drawing text on a bitmap, I need to know the handle of the selected font, specified by name, say 'Arial'. This is my last attempt. Anybody knows, where IŽm still wrong?
function CallbackProc(
var AFontInfoVar : TEnumLogFont;
var AMetricVar : TNewTextMetric;
AFontType : DWORD;
FontInfo : TLogFont) : Integer stdcall;
begin
AMetricVar := AMetricVar; // avoid FPC hint 'not used'
AFontType := AFontType; // dito
FontInfo := AFontInfoVar.elfLogFont;
Result := 0; // assume success and stop enumeration
end;
function GetFontHandle(
const AFontName : String) : hFont;
var
FontInfo : TLogFont;
begin
EnumFontFamilies(
DeviceContext,
PChar(AFontName),
@CallbackProc,
LongInt(nil + @FontInfo)
);
Result := CreateFontIndirect(@FontInfo);
end;
Thanks in advance
Wolfram
More information about the fpc-pascal
mailing list