Microsoft KB Archive/230382

= PRB: Accessing Printer Object's ScaleX, ScaleY Methods Prints Unwanted Page =

Article ID: 230382

Article Last Modified on 5/13/2003

-

APPLIES TO

 Microsoft Visual Basic 4.0 Professional Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95

 Microsoft Windows 98 Standard Edition  Microsoft Visual Basic 4.0 16-bit Enterprise Edition, when used with:  Microsoft Windows NT 4.0</li></ul>

 Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q230382

<div class="symptoms_section">

SYMPTOMS
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.

<div class="cause_section">

CAUSE
The Internal Printer Object code initializes the Printer Object in such a way that a new page is sent to the Printer.

<div class="resolution_section">

RESOLUTION
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

<div class="moreinformation_section">

MORE INFORMATION
Starting with Microsoft Visual Basic version 6.0, this behavior is no longer present.

Steps to Reproduce Behavior
<ol> Create a new project in Visual Basic 4.0 16-bit Edition.</li> Place a Command Button (Command1) on Form1.</li>  Paste the following code into the code window. Private Sub Command1_Click Debug.Print Printer.ScaleX(Printer.Width, vbTwips, vbInches) Debug.Print Printer.ScaleY(Printer.Height, vbTwips, vbInches) End Sub </li></ol>

Run the program and click Command1. A blank page will be printed out.

<div class="references_section">