Re: PrintForm method, no controls print
- From: "Mike Williams" <mike@xxxxxxxxxxxxxxxxx>
- Date: Sun, 17 Feb 2008 19:48:33 -0000
"Randy Gardner" <RandyGardner@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A5A8DE7B-BFE0-4FAE-A26E-43298D07C5B6@xxxxxxxxxxxxxxxx
Hi Mike: The routine work great, except I think I'm trying
to cram 20", screen size, of stuff on 8 1/2 x 11" of paper.
Your routine print almost exactly 8 1/2 x 11" of the screen
image.
Actually the code I posted is capable of printing the Form to the page at whatever size you wish, but before I tell you how to do that I think it might be wise to first say a few words about screen displays and printer pages in general (after addressing the next couple of questions).
I thought I read that PrintForm scaled the screen form
to the printer page
No. The VB PrintForm method just prints the Form at its full logical size. Any part of the Form which does not fit onto the page just gets clipped (except perhaps a few special printers might just place the "missing parts" on separate pages).
I'm trying to see if I can get away with using a standard
printer to create an emailable document for significatant
points of data. Can you help with that goal?
Yes. There are lots of different ways of doing it, and there are even ways of creating an emailable document without using a printer driver at all, and I can help you with all of those things. But I'm afraid I don't fully understand your question? Originally you asked for a way to print a Form to a printer page. Now you are saying that you want to create an emailable document for significant points of data. I do not understand the "significant points of data" part of your question? What exactly do you mean by that?
My program is a workstation application that
requires a large screen, in my case it is 20".
Okay. As I've said, I can help you with the things you have mentioned but first I think a few words of explanation regarding the screen size and the paper size thing won't go amiss.
When you say you are using a "20 inch screen" I assume you mean that you are using a 20 inch monitor. Is that what you mean? If so then you need to know that the actual physical size of the monitor does not really mean very much as far as the logical size of the graphics on your display (your Form for example) is concerned. On a standard "flat screen LCD monitor" (the things most people are using today) the "20 inch" actually refers to the actual physical diagonal size of the screen (from bottom left corner to top right corner). On an old fashioned (but still very useful!) standard CRT monitor the "20 inch" is essentially a "salesman's pitch" intended to "con" you and it refers to the diagonal size of the face of the glass CRT tube. However, on CRT monitors an inch or more of the actual glass screen is hidden inside the edges of the case (deliberately, because of screen curvature) and so the actual physical diagonal size of a "20 inch CRT monitor" (the size as measured when you hold a measuring rule against the front of the monitor) is probably about 18.5 or 19 inches. In both cases (the LCD monitor and the CRT monitor) these measurements relate to the actual physical size of the display, a measurement which is usually something quite different to the "logical size" of your screen as far as Windows is concerned . . .
.. . . Windows uses "logical" units when dealing with the size of your screen. These are "logical inches", logical centimetres", logical twips", etc, etc. All of these units have exactly the same relationship to each other as do their "real world" equivalents. For example, there are 2.54 "logical centimetres" in one "logical inch" just as there are 2.54 "real world centimetres" in one "real world inch". The basic units which determine the logical size of your display are pixels, and the logical size of a pixel is determined by a setting in the Windows Registry, and it can be different on different machines (or even different on the same machine if you alter those settings).
For example, if your machine is running at the standard "96 dots per inch" setting and if it is running the display at screen area (often called "resolution") of 1280 x 960 pixels then the "logical size" of your display is 13.33 x 10 inches (1280/96 x 960/96). The same machine, running at the same 96 dpi setting but at a screen resolution of 1024 x 768 pixels, would have a logical size of 10.66 x 8.00 inches. The actual physical size of the monitor has got nothing whatsoever to do with it.
.. . . I was going to carry on with a further more detailed explanation of this stuff, but i'm afraid time is running out on me at the moment so if you have any questions then post again.
In the meantime, you can use the code I posted to print your Form at whatever size you require (although printing "bitmap dumps" of screen images to a printer page is definitely not ever going to give you decent output and I would strongly advise you to use a different method of producing your printed document, as I mentioned in my earlier response).
Forgetting the "unprintable margins" of a printer (which I briefly mentioned in my previous response but which I do not have time to expand on here) you can use the code I posted to print your Form at whatever size you wish. On the assumption that your computer display is in landscape mode (as is the norm) and that you therefore want ot print the Form in landscape mode then this code (below) will print your Form at such a size that it exactly fills the entire printable area of the printer page. Does that help you at all?
Naturally there is a lot more I would like to say on this subject, but time is pressing at the moment so I cannot fit in everything I want to say (I reckon quite a few people will be extremely pleased with that, because I do tend to "waffle" from time to time!), but if your final goal is to produce a document that you can email to somebody else so that they can print it themselves (as it would appear might be the case) then post back and you'll get lots of help on it from lost of people.
Anyway, here's some example code. The output quality is nothing like the extremely high output quality that you could achieve using one of the alternative methods I have hinted at, but it might just suit your needs:
p.s Please forgive any "typos", my fingers are on fire here ;-)
Mike
Option Explicit
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Form_Load()
picBuffer.Visible = False
picBuffer.AutoRedraw = True
picBuffer.BorderStyle = vbBSNone
End Sub
Private Sub Command1_Click()
Dim oldMode As Long
oldMode = Me.ScaleMode
Me.ScaleMode = vbPixels
picBuffer.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
picBuffer.Cls
DoEvents
BitBlt picBuffer.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, _
GetDC(Me.hwnd), 0, 0, vbSrcCopy
Printer.ScaleMode = vbInches
Printer.Orientation = vbPRORLandscape
Printer.Print
Printer.PaintPicture picBuffer.Image, 0, 0, _
Printer.ScaleWidth, Printer.ScaleHeight
Printer.EndDoc
Me.ScaleMode = oldMode
End Sub
.
- References:
- PrintForm method, no controls print
- From: Randy Gardner
- Re: PrintForm method, no controls print
- From: Mike Williams
- Re: PrintForm method, no controls print
- From: Randy Gardner
- PrintForm method, no controls print
- Prev by Date: Re: PrintForm method, no controls print
- Next by Date: Re: VB6 works fine on XP but not Vista - Error 445
- Previous by thread: Re: PrintForm method, no controls print
- Next by thread: Re: PrintForm method, no controls print
- Index(es):
Relevant Pages
|