Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controversy 101: What Is The MAIN Useful Function Of Twips 2

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
US
What Are Twips Good For...???

If Pixels Are the Actual Dots on the Screen...
Why Have Twips that are ~ 15 twips per pixel???

You Can Not make 15 dots, much less 225 (15*15) dots inside a pixel on the screen...

Pixels have been used since Dos and probably before...

Why Does Windows (And VB in this case) Default to Twips...

Anything you Do with Graphics... (Pretty much what Windows is...) Requires Pixels...

If you are/were used to Dos... (and most programmers were at one point or another...) You know that in the old Screen Mode 13 (320x200x256color) A command Line(0,0)-(320,200) would make a line all the way accross the screen...
with Twips... Given the Same Graphic Area... It crosses only 21 pixels on X, and 13 on Y...

Does Anyone know WHY they decided to switch to twips???

AND is there a way to set your VB ide to default to Pixels as opposed to Twips, somewhere in the Setting/Options...

To Avoid Confusion... I Know how to set the ScaleMode... That is not the question...

Is there a situation where Twips Can prove to be of more use than Pixels?... If so, what are those situations? Sometimes... the BASIC things in life are the best...
cheers.gif

or at least the most fun ;-)
-Josh Stribling
 
Why are twips useful? Because they are independant of the rendering device's resolution. So something you draw that is 1440 twips wide will be an inch wide on a 72dpi screen display, and on a 300dpi printer, and on a 600dpi printer and on a 2400lpi linotype.

On the other hand, something you draw that is 72 pixels wide will be an inch on the aforementioned screen, 0.24 inches on the 300dpi printer, 0.12 of an inch on the 600dpi printer, and a miniscule 0.03 inches (i.e. less than a millimeter) on the linotype...
 
So they are mainly for printer scale purposes?

I you do not intend to print the applications data... is there a way to change the IDE defaults to Pixel...

...or do you have to physically change the templates? Sometimes... the BASIC things in life are the best...
cheers.gif

or at least the most fun ;-)
-Josh Stribling
 
I know of no way of changing the base units for a form, only it's scale mode - and, yes, you can do that through a template.
 
CubeE101 - "So they are mainly for printer scale purposes?"

No as strongm says they are independent of all devices not just printers.
If I want to write a cad application that is running on 2 different machines one with a high DPI monitor and another with a Lower DPI monitor and it spits stuff out to a plotter, a printer, and a CAM system all measurements are the same.
a twip is 1/20th of a point a point is 1/72nd of a inch
now many drivers don't correctly adjust the twips for different monitors but the capability is there.

It is based on print standards.

I've found that I'm pretty good at working with twips these days. Typical vidoe cards and monitors are 15 twips per pixel, my normal text boxes are 315 twips or 21 pixels. Normal labels are 17 pixels or 255 twips, etc.

 
I see your point...

So are twips like the common link between All the different scale modes...

Usually if I am making (or working with) a CAD program... I use Inch, Millimeter, or Centimeter...

Graphics stuff is usually Pixels...

and for Bore Forms... I just leave whatever and use the grid.

Now these Are ScaleModes...
And are Scaled from the Actual Twips...(?)

So the form and everything are still in twips... but I get to use the Scaled versions for the number crunching...

When you say device Independent... Do the twips change from monitor (driver) to monitor, and printer to printer,...
Or from screen mode to screen mode...?

Thanks Ya'll... Sometimes... the BASIC things in life are the best...
cheers.gif

or at least the most fun ;-)
-Josh Stribling
 
Interesting.
My screen is 1280x1024 pixels. I've set the width of a form to e.g. 10000 twips and measure the width on my screen to say 10 cm. Then I change my screen resolution to 800x600 pixels and what you say is that the form should still be 10 cm wide?
I've just tested and it is not the case (not at all)....

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
No - screen inches are, sadly, what are known as 'logical' (or nominal) inches.

There are good reasons for this. For example (and as you say), if I run a resolution of 1024 x 768 on a 17" monitor and on a 21" monitor then clearly things are bigger on the 21" monitor.

In theory, the display drivers should query both the resolution you are running at and the size of the display and thus calculate the correct twips ratio. In practice most drivers don't bother to do this, and assume that all displays are 72dpi and measure 320mm x 240mm
 
So does that lead to the conclusion that twips are after all only usefull when printing? Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Not in my opinion sunaj. The twip is a universal measurement - that being 1/20 of a point (TWentIeth of a Point. And of course, we have the standard 72 points per inch, which you are correct, was established in typography. The inability of some device drivers to accuraly resolve the proper number of twips to the rendering device does not relegate the usefulness of the twip only to printing, but rather, IMHO, exposes a deficiency in the device driver.

That being said, from a practical standpoint, you're probably correct. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Yep, it's a deficiency of the device driver. Ideally the graphics driver should be able to query the physical display to find out the real world height and width and then change the twipsperpixel setting appropriately, based on the resolution you have selected.

We can emulate this in code for a form:
[tt]
Private Sub Command1_Click()
Dim lp As Long
Dim ViewFactorX As Long
Dim ViewFactorY As Long
Dim WindowFactorX As Long
Dim WindowFactorY As Long

ViewFactorX = Screen.Width ' logical width in twips
ViewFactorY = Screen.Height ' logical height in twips

WindowFactorX = InputBox("Physical display width in inches:") * 1440 ' 16 is physical display width in inches
WindowFactorY = InputBox("Physical display height in inches:") * 1440 ' 11.5 is physical display height in inches
Form1.ScaleMode = vbTwips
SetMapMode Form1.hdc, MM_ANISOTROPIC
SetWindowExtEx Form1.hdc, WindowFactorX, WindowFactorY, ByVal 0&
SetViewportExtEx Form1.hdc, ViewFactorX, ViewFactorY, ByVal 0& ' GetDeviceCaps(Form1.hdc, LOGPIXELSX), GetDeviceCaps(Form1.hdc, LOGPIXELSY), ByVal 0&
Line (0, 0)-(1440, 1440), , BF ' Box drawn should measure 1" by 1" if you got your physical measurements correct

End Sub
 
Here's another monkey wrench to through in - not all displays are 72dpi or 96dpi. The new IBM display (to be used for medical imaging) is 123dpi. See more at
Note that this is an article from year 2000, and they talked about a 200dpi display prototype. It's probably on sale now (and probably costs more than my car).

Chip H.
 
Quite so. However, the fact that basic graphics drivers are 'lazy' about this doesn't eliminate the fact that Windows graphical subsytems can quite happily deal with differing graphical resolutions...as long as you are comfortable working with device independant measurements (twips are just one of several).
 
Since 92 when I first started windows programming I've seen systems with twips per pixel anywhere from 11 to 21 and often in the old days x and y had different values for twipsperpixel. Lately 95% or more systems seem to be 15 on both x and y. So the real problem like Strongm says is that most video drivers are just a bit lazy or decided just not to bother since for a long time monitors where not plug and play and didn't have that info.
 
Excellent Thread! Tuna - It's fat free until you add the Mayo!
 
yes excellent thread - here, take some credit... Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top