Re: Re-size Print Preview
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Sat, 24 Sep 2005 09:17:49 +0100
"Jim Y" <j.s.yablonsky@xxxxxxxxxxxxxx> wrote in message
news:UYYYe.302042$5N3.18508@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I have a test program that permits display of the form (preview) at full
> size using a PictureBox on the screen. So far so good - it works. What
> must I do to permit the user to enlarge the display if something is too
> small to be read and they want enlarge it? What must I do to permit the
> user to reduce the display and view the entire page on the screen?
There are at least three (probably more than three) different ways of doing
this, and they all have their advantages and disadvantages. A simple
StretchBlt of your picture box image is one way that would enable you to
make the size anything you want, but I would definitely advise that you
should *not* use that method in your specific case (too much loss of detail
because of the very limited resolution of the original "image"). Of the
other two methods that I have in mind, one would permit very easy scrolling
of a "magnified or enlarged" image (in much the same way as you are
presumably currently crolling the full size page) and the other one would
make such scrolling more difficult (as far as the amount of code is
concerned) to accomplish. Much depends on how much magnification you wish to
provide. The "harder to implement" method would permit almost limitless
magnification, but if you are happy with up to two or three times the width
and two or three times the height then you can use the easier method. That's
quite a large magnification when you see it in practice, and it makes it
possible to fairly comfortably read text as small as 3 points in size. In
fact, even a 200 percent magnification makes it possible to read 4 point
text, and such a magnification (using the method I have in mind) would
require a contiguous block of memory of only about 13 megabytes for your
autoredraw picture box, an amount that is always available even on very low
end systems.
Basically what you do is create your picture box and set its ScaleWidth to
8.5 and its ScaleHeight to 11 and you use coordinates for your drawings and
text as though those units are inches (even though they are not). The actual
size of the picture box (Width and Height) does not matter. It can be almost
anything you wish. If you want it to display the page at "full size" (as you
currently seem to be doing) then you also set the Width and the Height to
8.5 and 11 respectively, first making sure that you set it's "container's"
Scalemode, at least temporarily, to vbInches. The "container" could either
be a Form or perhaps another Picture Box (I would suggest the latter). You
will of course need to maintain a variable of type Single (let's call it
"magnification") and in this case (full size page) you would set
"magnification = 1".
If instead you wanted a "200 per cent magnified page" you would set the
picture box Width and Height properties to 17 and 22 respectively, again
making sure that it's "container's" ScaleMode is vbInches when you do so but
you still set the ScaleWidth to 8.5 and the ScaleHeight to 11. Then you set
the variable "magnification" to 2. You will, of course, have to provide the
user with a facility to "scroll the very large page" within its container so
that he can see the various parts of it, but I notice that you already seem
to have provided such a facility for the vertical direction so it obviously
won't be any trouble for you to do the same for the horizontal direction as
well.
Alternatively, if you wanted a "smaller than full page" size (so that you
could fit the entire page onto the screen regardless of the user's display
size and resolution) you would set the picture box Width property to 8.5 *
0.7 and its Height property to 11 * 0.7 and you would set the variable
"magnification" to 0.7 also. Again, you would set the ScaleWidth to 8 and
the ScaleHeight to 11 (you never set these to values other than those).
Obviously I've chosen the value "0.7" at random. In practice you would
calculate that value such that the page would be displayed in full on
whatever size and resolution display is currently in use.
Because the ScaleWith is always 8.5 and the ScaleHeight is always 11 you can
draw your lines and circles and boxes and paint your pictures and metafiles
and things using those coordinates just as though they were real inches. The
only thing you need to do differently is the font size for whatever text you
write on the page (because the font size in VB is always set in "points",
and a point is a point, no matter what you set the ScaleWidth and
ScaleHeight to). So, when printing your text you should set the font size in
accordance with the current contents of the "magnification" variable (which
was set to 1, 2 or 0.7 in the above three examples). So, for example, if you
needed 12 point text you would use Obj.Font.Size = 12 * magnification.
There is a very slight catch to this (isn't there always!) because the
actual font sizes of True Type fonts are limited to "whole pixel" values,
and the size you get will be the size you ask for to the nearest whoole
pixel (which is very, very close to the desired size on a typical high
resolution printer and only "quite close" to the desired size of the rather
limited resolution of a typical monitor). However, unless you are printing
stuff that required clean and straight "fully justified text" you won't have
much problem with that. There are, of course, ways to achieve nice clean
fully justified text that justifies at exactly the same character on the
printer as it does on the screen, but I don't think you'll need to get into
that sort of stuff for your own specific application.
Anyway, that's the "bare bones" of it. I won't have time to write any actual
code for you (under orders to wash all the "green stuff" off the top of our
little motorhome today!) but I'm sure you will be able to code it yourself,
looking at the stuff you have already done.
Other people here may have other suggestions for you of course. This is just
one option for you to consider. The big advantage of this method is that the
print routines for your picture box and for your printer can be exactly the
same (obviously you would set the variable "magnification" to 1 when
printing to the printer). There may be a few points I've missed (in a bit of
a rush at the moment) but if there are I'm sure others here will point them
out for you.
Mike
.
- References:
- Re-size Print Preview
- From: Jim Y
- Re-size Print Preview
- Prev by Date: Re: Control Mute or Audio Volume
- Next by Date: Re: For days I have toiled...
- Previous by thread: Re-size Print Preview
- Next by thread: Re: Re-size Print Preview
- Index(es):
Relevant Pages
|