April 26, 2024, 01:35:11 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Settingf the Font

Started by Bruce Peaslee, May 13, 2012, 10:24:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

When I code:


SetFont(wMain, "", 15, 500)


which font gets set?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ZeroDog

It will be the default font that is used for windows.  From what I can see in the window properties settings (when I right click my desktop, select properties, choose the appearance tab, and click the advanced button), it's the same font that is used for titlebars.

LarryMc

The  SETFONT command uses the CreateFontIndirect API to set the font for the window/control.
The API, in turn, uses the contents of a LOGFONT structure.
The SETFONT command fills the LOGFONT structure based upon user input.
The font name, lfFaceName , is one of the LOGFONT elements.

QuotelfFaceName
A null-terminated string that specifies the typeface name of the font. The length of this string must not exceed 32 characters, including the terminating null character. The EnumFontFamiliesEx function can be used to enumerate the typeface names of all currently available fonts. If lfFaceName is an empty string, GDI uses the first font that matches the other specified attributes.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

Good information.

Thanks.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

If youhave changed the font and want to go back to the default system font you can use:

SENDMESSAGE(win,WM_SETFONT,0,TRUE)

Some code to play with:

$include "windowssdk.inc"
LOGFONT lf
uint hfont
window w1
OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
CONTROL w1,@button,"QUIT",10,100,100,50,0,23

PRINT w1,"Hello World"
move w1,0,30
'setfont (w1,"tahoma", 20, 700,0,23)
hfont=sendmessage(w1,WM_GETFONT,0,0,23)
if hfont=0
hfont =  GetStockObject(DEFAULT_GUI_FONT)
endif
getobject(hfont,len(LOGFONT),lf)
print w1,lf.lfFaceName
WAITUNTIL w1 = 0
END

SUB main(),int
select @MESSAGE
case @IDCREATE

centerwindow w1
case @IDCLOSEWINDOW
        CLOSEWINDOW w1
endselect
RETURN 0
ENDSUB


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library