Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How To Print a Form That Is Too Large for the Screen or Page
Article ID: 230502 - View products that this article applies to.
This article was previously published under Q230502
The PrintForm method prints only the portion of the form that is displayed. This article demonstrates how to print a form that is either larger than the screen or is only partially displayed.
If you need to print a form that is larger than the screen, or is only partially displayed, then the controls on the form must be placed in a PictureBox. This prints the bitmap that is contained in the PictureBox, instead of a screen capture of the form itself (which is what PrintForm does). Because the PictureBox's bitmap is stored in a device context in memory, you have access to the entire bitmap regardless of what is displayed.
NOTE: For the purposes of this article, the height of the form is set to 11 inches. If another paper size is desired, such as 8.5- X 14- inches, set the sTall variable to an appropriate value, for example, 14. Also note that these assignments are made in twips because this is the default scalemode for forms. If you change the scalemode, you need to change these values to match as well.
Print a Form That Is Larger Than the Screen
Print a Form on More Than One PageIf the form you are printing is too large to fit on a page, you can use the same approach as in the preceding example with a minor addition. The PaintPicture method has a number of optional parameters. The clipping region parameters can be used to grab a portion of the bitmap image and print it.
To accomplish this, locate the following code in the previous example:
Replace those three lines of code with the following:
For ease of illustration, this example merely divides the form in half. You can adjust the clipping region appropriately for your needs.
NOTE: Visual Basic 6.0 Online Help states that PrintForm prints the entire form, whether the entire form is visible or not. This information is incorrect.
For additional information about printing forms, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/178076/EN-US/ )How To Use a PictureBox to Control Orientation Printing a Form
(http://support.microsoft.com/kb/161299/EN-US/ )How To Capture and Print the Screen, a Form, or Any Window
(http://support.microsoft.com/kb/194580/EN-US/ )How To Print a Composite Image From a RichTextBox
146022Visual Basic Online Help; search on: "PaintPicture"
(http://support.microsoft.com/kb/146022/EN-US/ )How To Set Up the RichTextBox Control for WYSIWYG Printing
Article ID: 230502 - Last Review: July 1, 2004 - Revision: 3.1