- In the OnCreate event for the main form in your Delphi application call the AddFontResource API function. The AddFontResource function adds the font resource from the specified file to the system font table.
- When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function. Do this in the OnDestroy event for the main form.
procedure TForm1.FormCreate(Sender: TObject) ;
begin
AddFontResource('c:\FONTS\MyFont.TTF') ;
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
{Before application terminates we must remove our font:}
procedure TForm1.FormDestroy(Sender: TObject; var Action: TCloseAction) ;
begin
RemoveFontResource('C:\FONTS\MyFont.TTF') ;
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
Delphi tips navigator:
» Are we connected to the Internet?
« Get Windows version

