Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6: How to switch to pixels instead of twips

Tags:

vb6

I am refactoring a VB6 application. The measurements of any of the controls are in twips. Is it possible in VB6 to set a control to use pixels instead of twips? Thanks

like image 222
ezpresso Avatar asked May 02 '11 19:05

ezpresso


3 Answers

I worked extensively with scalemode back in the day and all I can say is don't bother. It wasn't properly universally supported, which meant that you'll end up converting back to twips for some things anyway.

VB6 is twips based, like it or not, so if you try to do things pixel based, you'll be fighting the current the whole way.

Fortunately VB.net finally ended all that, and is completely pixel based, you can still alter you viewport scaling but .net seems to handle that much better than Vb6.

like image 153
DarinH Avatar answered Sep 24 '22 11:09

DarinH


dim iInPixels as integer
dim iInTwips as integer

iInPixels = 200
iInTwips  = iInPixels * Screen.TwipsPerPixelX
iInPixels = iInTwips / Screen.TwipsPerPixelX

As @drventure said, you'll be rowing against the current the whole way, but it really isn't all that bad, as long as you can isolate the logic to a single spot.

like image 27
AngryHacker Avatar answered Sep 23 '22 11:09

AngryHacker


Does the ScaleMode Property help?

Returns or sets a value indicating the unit of measurement for coordinates of an object when using graphics methods or when positioning controls.

like image 45
Bob77 Avatar answered Sep 21 '22 11:09

Bob77