Re: VB Printer Dialog Problem (VB6)



<andy.vandierendonck@xxxxxxxxxx> wrote in message
news:1151855185.806811.78040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

. . . so that's why I'll never know how many pages
there will be print.

Okay, I was going to wait until you responded to my last message, but it's a
lazy old warm and balmy Sunday evening here and I've got time to spare and
nothing much to do with it, so I'll write a reponse on the assumption that
counting the pages before you print is your current problem. Before I go on
to that though, I think I'd better say a word or two about your "hard coded"
printing widths and positions and also about your page margins. There's
quite a bit, so please bear with me . . .

Firstly, in your very first posting in this thread you included code in
which you were setting printer.ScaleLeft to a value of -12 (millimeters). I
assume that you know that doing such a thing moves the print position of (x
coordinate zero) 12 millimeters to the right of the "unprintable left
margin", which on many printers is itself a little to the right of the left
edge of the physical piece of paper (about 3.5 millimeters on A4 paper on
injket printers). This means that your original code Printer.ScaleLeft = -12
will actually set the print margin of x coordinate zero to be about 15.5
millimeters from the left edge of the physical page. I'm not sure if this is
what you meant to do, and if you arrived at the value of -12 by trial and
error in order to produce an actual distance of 15, but if so then that's
fine (apart from the fact that it is not reliable because different printers
can have different sizes of "unprintable margins"). However, now that you
are using the SetPrinterOrigin routine that I posted the other day, which
you've changed to SetMargin in your code, I see that you are still using a
value of 12, Call SetMargin (12, y). The thing is that my SetPrinterOrigin
routine examines the printer to see exactly what the left "unprintable
margin" is on that specific printer, and it takes that into account when it
sets the ScaleLeft property. I wrote it that way deliberately so that the
user of it could specify a precise distance "from the left edge of the
physical piece of paper" and it would set ScaleLeft to exactly the required
amount so as to produce that exact "distance from the left edge of the
physical piece of paper" on all printers, regardless of the possible
differeces in their unprintable margins. This gives the user much less to
worry about. So, using SetMargin (12, y) with your ScaleMode of millimeters
will set x coordinate zero to exactly 12 millimeters from the left edge of
the page. If, as I suspect, you really wanted a distance of 15 millimeters
from the left edge of the page then you need to specify 15 (not 12) in your
call to the SetMargin routine, SetMargin (15, y). The same reasoning goes
for the top margin, because some printers also have an unprintable top
margin, of different size on different printers. My SetprinterOrigin routine
(now your SetMargin routine) automatically takes this stuff into account, so
if you want printer coordinate (0, 0) to point to a position 15 millimeters
from the left and 15 millimeters from the top then you simply use SetMargin
(15, 15) and it will work things out and do it automatically for you. Does
that help?

Secondly, I see you are using a "hard coded" value of 275 (millimeters) as
representing the bottom margin position. That is not a wise thing to do, and
I'll explain why this is so. Normally, the very bottom most position you can
print anything is at a y position equal to Printer.ScaleHeight. However, the
actual bottom most position you can print is (Printer.ScaleHeight +
Printer.ScaleTop). You can usually just use Printer.ScaleHeight simply
because most people usually leave the ScaleTop set at its default setting of
zero. However, in your case you have altered the printer.Scaleheight value
by calling my SetMargin routine. This means that if you want to calculate
the bottom most position you can print anything at you must use the proper
PrinterScaleHeight + Printer.ScaleTop. That of course is the bottom most
pixel you can print. As you obviously already know, the coordinates of a
string of text refer to the top edge of the characters, so they must be
printed a little higher (by the TextHeight value) if you want to see them.
I've just done a qick test using my own inkjet printer, which uses A4 paper,
and the bottom most pixel I can print, which is returned by
Printer.ScaleHeight + Printer.ScaleTop, after using SetMargin (15, 15) is
269.5. All printers are slightly different of course, but if you're using A4
paper yourself then you're sailing very close to the wind with your hard
coded value of 275. If you want to know the exact bottom most pixel you can
print on the page on your own setup then PrinterScaleHeight +
Printer.ScaleTop will give you the exact value.

You need to treat your x coordinates similarly, with the right most position
you can print a pixel being given by Printer.ScaleWidth + printer.ScaleLeft.

Well, I'm afraid this is taking a bit longer than I thought (I can feel the
heat building up on these keys!). I meant to go on to tell you about page
numbers and I haven't even finished this first "blurb" yet! I need to go on
to tell you how to calculate exact right and bottom margins yet, so that you
can make your printing nice and balanced on the page. I'll have to leave
that (and the page numbers thing, and a few other things) to later I'm
afraid, or maybe tomorrow.

Anyway, by then you'll have probably posted again and I'll have a bit more
feedback to go on.

Mike





.



Relevant Pages

  • Re: Format Issues
    ... Margins are 5mm all round (top, bottom, left, right) and paper size is ... the open event of me report? ... Most of the printers in my company would not support ... important one is the bottom margin. ...
    (microsoft.public.access.reports)
  • Re: Margins are way off, can not be changed in Access 2003
    ... Sounds like the printers margin. ... > another printer for a report, the margins change to 5.095 bottom and 4.096 ...
    (microsoft.public.access.reports)
  • Re: Printing a form (not VB form) like PDF or similar
    ... printing at 1/4 inch or less from the top and sides, ... from the bottom, so the borders are not really a major problem. ... saving as a metafile for use in your program. ... If so then you need to be aware that not all printers can ...
    (comp.lang.basic.visual.misc)
  • Re: Printing a form (not VB form) like PDF or similar
    ... need to load in the appropriate metafile and its associated data file ... to be about a quarter of a inch from the bottom of the page. ... If so then you need to be aware that not all printers can ... fgoing closer than about half an inch from the bottom of an A4 page. ...
    (comp.lang.basic.visual.misc)
  • Need suggestions for a printer.
    ... After checking out several printers and flipping through various ... The fact that the bottom margin is ... Takes pigment black ink. ... If it doesn't take giant cartridges, ...
    (comp.periphs.printers)