Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Twips vs Pixels

14 views
Skip to first unread message

Aoli

unread,
Mar 12, 2022, 2:17:17 PM3/12/22
to

I am not talking about using .TwipsPerPixelX etc.

Have a form with pictureboxes, frames, other controls.

What is the correct way to set the ScaleMode)s) in this case so as not
to have to do a lot of conversions.

Poor example.
Form set to pixels.
center a frame fra2 within a frame fra1
(fra1.With - fra2.Width)\2 yields a fra2 not centered but off sightly
to the left in fra1. needed to do a +80 to get closer to center.

With pictureboxes setting the scalemode to pixels then trying to fit
within the form yields pictureboxes of a smaller dimension than
expected. picturebox.scalewidth refers to pixels but width refers to what?

Where do I find the complete set of rules for all of this ?
Rules of thumb ?

John K.Eason

unread,
Mar 12, 2022, 7:21:19 PM3/12/22
to
In article <t0irjl$75j$1...@gioia.aioe.org>, Ao...@Aoli.com (Aoli) wrote:

> *From:* Aoli <Ao...@Aoli.com>
> *Date:* Sat, 12 Mar 2022 11:17:10 -0800
The default form scalemode is Twips not pixels, To centre Frame1 on a form with
Frame2 centred inside it use:

Frame1.Left = (Me.ScaleWidth / 2) - (Frame1.Width / 2)
Frame2.Left = (Frame1.Width / 2) - (Frame2.Width / 2)

where 'Me' is the containing form. The ScaleWidth takes account of possible form
border size offsets.
Not sure where the docs are on the coordinate system nowadays. You really want to
get hold of a copy of Balena's Programming Visual Basic 6 (ISBN 0 - 7356 - 0558 -0)
if you can which contains all the grisly details plus much more. (1275 pages!)

--
Regards
John (jo...@jeasonNoSpam.cix.co.uk) Remove the obvious to reply...

ObiWan

unread,
Mar 14, 2022, 4:34:45 AM3/14/22
to
:: On Sun, 13 Mar 2022 00:21 +0000 (GMT Standard Time)
:: (microsoft.public.vb.general.discussion)
:: <memo.20220313...@jeason.cix.co.uk>
:: jo...@jeasonNoSpam.cix.co.uk (John K.Eason) wrote:

> The default form scalemode is Twips not pixels, To centre Frame1 on a
> form with Frame2 centred inside it use:
>
> Frame1.Left = (Me.ScaleWidth / 2) - (Frame1.Width / 2)
> Frame2.Left = (Frame1.Width / 2) - (Frame2.Width / 2)
>
> where 'Me' is the containing form. The ScaleWidth takes account of
> possible form border size offsets.
> Not sure where the docs are on the coordinate system nowadays. You
> really want to get hold of a copy of Balena's Programming Visual
> Basic 6 (ISBN 0 - 7356 - 0558 -0) if you can which contains all the
> grisly details plus much more. (1275 pages!)

Totally correc, John, as for Twips let me add a note; the "Twip" unit
is a typographical unit which was adopted since it simplifies some
tasks; that is, independently from a given device DPI (and resolution),
using twips we'll always know that 1440 twips equals one inch, this
means that if we design a form which has a size of 10"x8" that form
will have the same size independently from the screen resolution, the
same goes if we draw a shape on a printer, using twips the shape will
have the same size in inches independently from the printer DPI value

John K.Eason

unread,
Mar 14, 2022, 8:03:46 AM3/14/22
to
In article <20220314093...@mvps.org>, obi...@mvps.org (ObiWan) wrote:

> Totally correc, John

Phew! :^))

ObiWan

unread,
Mar 14, 2022, 11:36:23 AM3/14/22
to
:: On Mon, 14 Mar 2022 12:03 +0000 (GMT Standard Time)
:: (microsoft.public.vb.general.discussion)
:: <memo.20220314...@jeason.cix.co.uk>
:: jo...@jeasonNoSpam.cix.co.uk (John K.Eason) wrote:

> In article <20220314093...@mvps.org>, obi...@mvps.org
> (ObiWan) wrote:
>
> > Totally correc, John
>
> Phew! :^))

LOL !

Seriously, many years ago had to write some code for a ship line
ticketing system, the tickets had to carry some data and a barcode to
speed up the check-in process, to avoid using external stuff like the
(darn, I hate it!) "Crystal Reports" or something like that I decided
to use a (hidden) form as my printed form, basically I placed a number
of simple object arrays like rectangles images and labels on it, then
the code handled the resising of the "print form" as needed, loaded and
positioned the additional objects and populated them with the data
which came from a DB (the bar code was generated on the fly as an
image); using twips as the unit made the whole thing easy and it also
helped avoiding issues in case offices had different printers with
different DPI values, it worked like a charm :)





John K.Eason

unread,
Mar 14, 2022, 8:20:30 PM3/14/22
to
In article <20220314163...@mvps.org>, obi...@mvps.org (ObiWan) wrote:

> *From:* ObiWan <obi...@mvps.org>
> *Date:* Mon, 14 Mar 2022 16:36:19 +0100
Yes indeed. I used to create specially laid-out pages of results for our county
rifle competitions. However I cheated a bit by printing them to a PDF printer and
then emailing the PDFs to the clubs! :^)
I retired from doing that this year after 35 years!

ObiWan

unread,
Mar 15, 2022, 4:57:09 AM3/15/22
to
:: On Tue, 15 Mar 2022 00:20 +0000 (GMT Standard Time)
:: (microsoft.public.vb.general.discussion)
:: <memo.20220315...@jeason.cix.co.uk>
:: jo...@jeasonNoSpam.cix.co.uk (John K.Eason) wrote:

> Yes indeed. I used to create specially laid-out pages of results for
> our county rifle competitions. However I cheated a bit by printing
> them to a PDF printer and then emailing the PDFs to the clubs! :^)
> I retired from doing that this year after 35 years!

Yep, that's the point; as for the PDF format, that reminded me of a
trick I used time ago, basically I installed a virtual printer port
using "redmon"

http://www.ghostgum.com.au/software/redmon.htm

now, that little program sets up what's called a "port monitor" ie a
"virtual port" to which you can connect whatever printer, usually (as in
my case) you'll select a vanilla postscript printer, but you can also
use other printers if needed ... then comes the fun, start by having a
look here

http://www.ghostgum.com.au/software/redmon19.htm

Now, the simplest use of the setup is to configure the virtual port
telling it to start a program when a printer job comes in and let it
handle the job; in this case you will usually set things up so that
when the printed output arrives (it's a PS format file) it will be
passed over to "GhostScript"

https://pages.cs.wisc.edu/~ghost/

the latter will read the "PS" file and convert it to whatever output
format including PDF, but ... you could use an intermediate program too
:) for example, let's say you write a program in VB (or whatever other
language) and configure "redmon" to run it whenever a job arrives, now
your VB code could (just an example btw) run ghostscript to convert the
PS file to a PDF or a TIFF and, once done that, send the file as an
attachment through email and/or save it to a NAS...

As you can see, using the above approach allows to play some quite
interesting tricks :) in my case, my VB code extracted a phone number
from the PS file (it was added by another program), used ghostscript to
convert the PS to a TIFF and then sent the TIFF to a fax using the fax
specific API which btw needed to specify a phone number :D


0 new messages