Well, "little" doesn't really mean "quick" here, as I had to scratch together the objects involved from all corners of the CTS. The Handle property of the text box, for instance, is not found in the docs on the TextBox class itself. It is rather inherited indirectly from the IWin32Window implementation in System::Windows::Forms::Control. Note that the Graphics object here is not used to actually draw something, but merely for the size calculation.
If you are interested in more elaborate information about this, feel free to ask. I was already thinking of writing a little text size calculator anyway and might post it here if you're interested. This would take some time to write, though.
The text size specification in the attached image has been generated by the code posted above, for instance. Note that the height specification is not equal to the font size because it accounts the entire line spacing rather than just the height of a norm character.
The width of a single digit in MS Sans Serif 8.25, BTW, is 7.47522 pt, measured using the same method. But the width measured for 8 digits is 40.15576 pt, which obviously is not 8 times the value for the single digit. Maybe I should investigate some more about how that measurement actually works...
Last edited by Eri523; October 18th, 2010 at 09:40 PM.
Reason: Corrected where the text box' Handle property actually is derived from
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.