I know I would use WM_SETFONT but how do I get the font handle. I want to use one of the fonts from the system folder is there a api that takes a file name of a ttf and returns it's handle? The only one I could find was CreateFont but that seams to require that you allready know it's height etc.
Posted on 2002-04-13 14:40:11 by Kudos
Hi Kudos

To create a font and set it to a control:



.data

szFaceName db 'MS Sans Serif',0

.data?

lfnt LOGFONT <?>

.code

;Create font
invoke RtlZeroMemory,addr lfnt,sizeof lfnt
mov lfnt.lfHeight,-12
mov lfnt.lfWeight,400
invoke lstrcat,addr lfnt.lfFaceName,offset szFaceName
invoke CreateFontIndirect,addr lfnt
mov hFont,eax
;Set font
invoke SendMessage,hWin,WM_SETFONT,hFont,0


KetilO
Posted on 2002-04-13 15:48:42 by KetilO
i don't know if this is what you are looking for, you could try looking into:
AddFontResource
which will add the font into the sys. font tbl.
and then creating the font /w CreateFont.

CreateFont needs you to specify the parameters of the font you want to display. just specify the font size you want for nHeight.

hm... KetilO seems to have beaten me to it ;)
Posted on 2002-04-13 15:49:41 by jademtech
you should use deleteobject when you no longer need it otherwise you will have memory leak


bye

eko
Posted on 2002-04-13 16:05:43 by eko
thanx KetilO, that works great

Do I use DeleteObject When I have no more controls that need to be set to use the font or when the last control using it has been destroyed?
Posted on 2002-04-13 18:29:50 by Kudos
Hi Kudos

Delete it when you terminate your app, or when all controls that are using it are destroyed and you dont intend to use the font anymore.

KetilO
Posted on 2002-04-13 19:42:42 by KetilO