determine system default font size

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
danca
Posts: 13
Joined: Wed Mar 16, 2016 7:09 pm

determine system default font size

Post by danca »

Hi all,
in order to rightly dimension the controls, I need to determine the default font size at program start.
I noticed that in a test machine using font sized at 125% buttons and other controls were badly sized with text inside truncated and, worst of all, some editboxes were just not editable. :x

After digging in sources I found the function HMG_getAverageFontSize and now, finally, i get for one machine 7 x 16 and for the other one 9 x 20 :mrgreen:
Here is the function executed ON INIT:
function my_setfontsize()
local nFontWidth, nFontHeight, lNoErr
local wh:=getFormHandle("mainwindow")
lNoErr=HMG_getAverageFontSize(wh,@nFontWidth,@nFontHeight)
if lNoErr
msgInfo("System default font size:"+str(nFontWidth)+"x"+str(nFontHeight))
else
msgInfo("An error occurred")
endif
return nil

It costed me a fair amount of time, digging in this forum first and in sources then. (And a lot of trials and errors ...)
I wonder if there is a simpler way :shock:
Good programming to all!
Dan
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: determine system default font size

Post by serge_girard »

Thanks Dan for this useful function!

Serge
There's nothing you can do that can't be done...
Post Reply