Microsoft KB Archive/173981

= PRB: Behavior Differences of Print Dialog Box on Different Platforms =

Article ID: 173981

Article Last Modified on 5/13/2003

-

APPLIES TO

 Microsoft Visual Basic 5.0 Learning Edition, when used with:  Microsoft Windows XP Professional

 Microsoft Windows 2000 Standard Edition

 Microsoft Windows NT 4.0

 Microsoft Visual Studio .NET 2002 Professional Edition</li></ul> </li> Microsoft Visual Basic 6.0 Learning Edition, when used with:  Microsoft Windows XP Professional</li></ul>

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

 Microsoft Windows NT 4.0</li></ul>

 Microsoft Visual Studio .NET 2002 Professional Edition</li></ul> </li> Microsoft Visual Basic 5.0 Professional Edition, when used with:  Microsoft Windows XP Professional</li></ul>

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

 Microsoft Windows NT 4.0</li></ul> </li> <li>Microsoft Visual Basic 6.0 Professional Edition, when used with: <ul> <li>Microsoft Windows XP Professional</li></ul>

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

<ul> <li>Microsoft Windows NT 4.0</li></ul> </li> <li>Microsoft Visual Basic 5.0 Enterprise Edition, when used with: <ul> <li>Microsoft Windows XP Professional</li></ul>

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

<ul> <li>Microsoft Windows NT 4.0</li></ul> </li> <li>Microsoft Visual Basic 6.0 Enterprise Edition, when used with: <ul> <li>Microsoft Windows XP Professional</li></ul>

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

<ul> <li>Microsoft Windows NT 4.0</li></ul> </li> <li>Microsoft Visual Basic 4.0 Standard Edition, when used with: <ul> <li>Microsoft Windows XP Professional</li></ul>

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

<ul> <li>Microsoft Windows NT 4.0</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q173981

<div class="symptoms_section">

SYMPTOMS
On Windows XP, Windows 2000, or Windows NT 4.0, when you call the ShowPrinter method of the CommonDialog control, some of the properties of the Printer object, such as the Copies and the Orientation properties, are not affected by changes that the user selects in the Print dialog box.

This problem does not occur with the same properties of the Printer object on Microsoft Windows Millennium Edition (Me), Microsoft Windows 98, or Microsoft Windows 95.

<div class="cause_section">

CAUSE
This problem occurs because the Printer object and the CommonDialog control do not share information. The object and the control have their own device context. For more information, see the "References" section.

<div class="resolution_section">

RESOLUTION
You can work around this problem for the properties that the CommonDialog control exposes. To demonstrate this, replace the code for Form1 of the sample project in the "More Information" section with the following code, which assigns the property values from the CommonDialog control to the Printer object: With CommonDialog1 .ShowPrinter Printer.Copies = .Copies Printer.Orientation = .Orientation Debug.Print "Copies = " & CStr(Printer.Copies) & vbCrLf & _ "Orientation = " & CStr(Printer.Orientation) End With

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
The CommonDialog control only exposes the following properties:
 * Copies
 * FromPage
 * ToPage
 * Orientation
 * PrinterDefault

If you need any other information from this dialog box, you must use the Print dialog box application programming interface (API) functions (either the PrintDlg or the PageSetupDlg function) that access and change the printer properties. Because of packing alignment issues for structures in Visual Basic 6.0, calling Print dialog box functions directly is unnecessarily complex. Therefore, Microsoft recommends that you call these functions from a C dynamic-link library (DLL) such as the C DLL that is included in the following Microsoft Knowledge Base article: For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

322710 HOWTO: Raise and Control Print Dialogs from Visual Basic

Steps to Reproduce the Behavior
<ol> <li>Create a new Standard EXE project. Form1 is created by default.</li> <li>Add a CommandButton control and a CommonDialog control to Form1. The controls are named Command1 and CommonDialog1 by default.</li> <li> Add the following code to Form1: Private Sub Command1_Click With CommonDialog1 .ShowPrinter Debug.Print "Copies = " & CStr(Printer.Copies) & vbCrLf & _ "Orientation = " & CStr(Printer.Orientation) End With </li> <li>Press F5 to run the application.</li> <li>Click Command1.</li> <li>In the Print dialog box, change the number of copies and the orientation, and then click OK. Notice that Copies and Orientation appear as 1 in the Debug (Immediate) window, regardless of the settings that you selected in the Print dialog box.</li></ol>

<div class="references_section">