desktop fonts

BlitzPlus Forums/BlitzPlus Programming/desktop fonts

Lazze(Posted 2004) [#1]
Does anybody know how to retrieve the dekstop fonts? I want to make my app as consistent with windows as possible, so I want to use the fonts the user has set for the desktop. I specifically need them to scale my gadgets to fit the fonts properly.

Lazze


soja(Posted 2004) [#2]
You could use SystemParametersInfo from the Windows API (available for Win95+ in user32.dll). You can specify parameters like SPI_GETICONTITLELOGFONT. Is that what you mean?


Lazze(Posted 2004) [#3]
Yes - I think so....but how do I go about that? I'm really not into this API-stuff...

Lazze


soja(Posted 2004) [#4]
It was a little more difficult than I figured, but something like this will get you the font name and size (in points)
; Desktop Icon Info Example by soja

; .lib "user32.dll"
; SystemParametersInfo%(uiAction%, uiParam%, pvParam*, fWinIni%):"SystemParametersInfoA"
; GetDC%(hwnd%):"GetDC"
;
; .lib "gdi32.dll"
; GetDeviceCaps%(hdc%, nIndex%):"GetDeviceCaps"
;
; Look up "SystemParametersInfo" on msdn.microsoft.com for more info.

Const SPI_GETICONTITLELOGFONT = $001F
Const LOGPIXELSY = 90 ; Logical vertical pixels per inch

LOGFONT = CreateBank(40)
SystemParametersInfo(SPI_GETICONTITLELOGFONT, BankSize(LOGFONT), LOGFONT, 0)

Print "Desktop Icon Information"
f$ = "Face: "
a = 28
While PeekByte(LOGFONT, a) <> 0
	f$=f$+Chr$(PeekByte(LOGFONT, a))
	a=a+1
Wend
Print f$
Print "Height in Points: "+ (-72 * PeekInt(LOGFONT, 0)) / GetDeviceCaps(GetDC(0), LOGPIXELSY)
WaitKey



Lazze(Posted 2004) [#5]
COOL :o) - and many many thanks if it works - which I believe it does, mind you :o)(I just have to try it yet)

Lazze