PRB: Accessing Printer Object's ScaleX, ScaleY Methods Prints Unwanted PageID: Q230382
|
If you use the ScaleX and ScaleY methods of the Printer Object in Visual Basic version 4.0 (16-bit) you produce an unwanted printed page when running on Windows 95, Windows 98 or Windows NT version 4.0.
The Internal Printer Object code initializes the Printer Object in such a way that a new page is sent to the Printer.
ScaleX and ScaleY values can be retrieved through a call to GetDeviceCaps using HORZSIZE and VERTSIZE. The values returned should be converted to the units desired. This will give you the size of the printable area for the Printer's printed page.
Const HORZSIZE = 4
Const VERTSIZE = 6
Const mmTOinches = 25.4
Private Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC%, ByVal nindex%) As Integer
Private Sub Command1_Click()
Dim iretvalH As Integer, iretvalV as Integer
' GetDeviceCaps returns value in millimeters
iretvalH = GetDeviceCaps(Printer.hDC, HORZSIZE)
iretvalV = GetDeviceCaps(Printer.hDC, VERTSIZE)
Print "Height in Inches:", (iretvalV / mmTOinches)
Print "Width in Inches:", (iretvalH / mmTOinches)
End Sub
Starting with Microsoft Visual Basic version 6.0, this behavior is no longer present.
Private Sub Command1_Click()
Debug.Print Printer.ScaleX(Printer.Width, vbTwips, vbInches)
Debug.Print Printer.ScaleY(Printer.Height, vbTwips, vbInches)
End Sub
For additional information about using GetDeviceCaps in the 32-bit version of Visual Basic, please see the following article in the Microsoft Knowledge Base:
Q193943 HOWTO: Use GetDeviceCaps to Determine Margins on a Page
Additional query words: Printer Object ScaleX ScaleY
Keywords : kbPrinting kbVBp400
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: June 2, 1999