LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Size of the text in a numeric control ?

Hello all,
I can't figure out a way to get the width (in pixel) of the value displayed
in a numeric control.
I want to make sure the control is large enough to display the entire text
of the entire value.

The only way I could think about was to get the Format, Padding and
Precision and try to generate a %f sprintf with that and then do a
GetTextDisplaySize with the correct font. Hard to get right.

I'm sure there must be a better way...
--
Guillaume Dargaud
http://www.gdargaud.net/
"The mime's opinion was a mute point."


0 Kudos
Message 1 of 2
(3,059 Views)

Hi,

 

I also know of no better way than using GetTextDisplaySize with a given metafont. I have a similar routine where I generate short path names that fit into a given text control width, and I am using this function to calculate the width of the text. For numbers, of course, it will depend on the formatting...

 

BUT, if you know your font in advance, say Arial, you can find out manually. This is the way I did it. For Arial, a minus sign is 5 pixels, a dot 3, and the exponent takes 22, for a digit 7 pixels are required. ... sorry if it's not a better suggestion.

 

Wolfgang

0 Kudos
Message 2 of 2
(3,048 Views)