Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Schrift aus Ressource nutzen (https://www.delphipraxis.net/147757-schrift-aus-ressource-nutzen.html)

himitsu 16. Feb 2010 21:14

Re: Schrift aus Ressource nutzen
 
Ich glaub die Übersetung von HANDLE nach HFONT war etwas falsch, jedenfalls wenn ich diesem glauben darf:

Zitat:

Calling the API AddFontMemResourceEx() will register/install the
font with the system font table and returns a HANDLE, you need to
use the APIs CreateFont(), CreateFontIndirect() to obtain a handle
to the font.

Du kannst InstalledFonts auch leer lassen, also nil eintragen.
Damit man nicht unbedingt eine Variable braucht, wenn man es eh nicht wissen will/muß, hab ich es nicht als VAR-Parameter ausgelegt.
PS: Hab es oben mal etwas geändert und man kann es jetzt auch ganz weglassen.

Delphi-Quellcode:
H := LoadResFont('MyFont');
if H = 0 then {error};
// ja, und nun muß man anscheinend nur noch einen HFONT auf diese geladene Datei bekommen
Aber CreateFont/CreateFontIndirect nehmen kein Handle entgegen, also wird man wohl über den Namen des Fonst gehen müssen?
Und kann dieses THandle nur noch zum Freigeben/Entladen des Fonts nutzen.

[Add] jupp, der Font muß ganz Normal über seinen Namen angesprochen werden.
Delphi-Quellcode:
FontHandle := LoadResFont(1);
if FontHandle = 0 then {error};
Canvas.Font.Name := 'anywhere';
Canvas.TextOut(10,10,'Foo Bar');
...
UnloadResFont(FontHandle);


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:03 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz