Pixels vs. Twips

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm building a simple Windows Form with tabs at the top. I'm writing some
code to ensure that each tab will be wide enough to accomodate the text that
will go in it - for both English and other languages.

So I used the MeasureString method to figure out the width of the text.
This came back in pixels. Fine. But then I went to the TabPage object to
get its width. To my great surprise the width value was in Twips, even
though articles like this say this isn't so:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vxconchangestoscreenobjectinvisualbasicnet.asp

>From previous experience in VB6 I've learned that one cannot always depend
upon 1 Pixel = 15 Twips. On some screen resolutions I've seen 1:12.

So, I'm wondering if the TabPage.Width value is a known bug in .Net and if
there's a workaround that anyone knows of.

Sincerely,

Robert W.
Vancouver, BC

.



Relevant Pages