Microsoft KB Archive/148891

= Printer setup is not remembered when you run an MFC application that was created by using Visual C++ 4.0 and later versions =

Article ID: 148891

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q148891

<div class="symptoms_section">

SYMPTOMS
As you run an MFC application that was created by using Visual C++ 4.0 and greater on Windows NT 3.51, the printer setup is not remembered. This behavior occurs only with Windows NT 3.51, not with Windows 95.

<div class="cause_section">

CAUSE
When an application displays the Print dialog box, displays the Print Setup dialog box, or goes into Print Preview, MFC calls the function CWinApp::UpdatePrinterSelection. MFC checks for the following conditions if the default printer is being used:


 * Default printer no longer has a printer.
 * Default printer has changed.
 * Default printer has not changed.

Depending on the results of these tests, MFC sets up the Device Names and the Device Mode variables in the PRINTDLG structure (m_pd) of the CPrintDialog object.

In evaulating whether the default printer has changed, MFC checks to see if the Driver Name, Device Name, and Port Name has changed by comparing these parameters against the defaults obtained from using PD_RETURNDEFAULT. In Windows NT 3.51, ::PrintDlg is not obtaining the same Port Name when using PD_RETURNDEFAULT as it does when it obtains the Port Name from displaying the print dialog. Therefore, the overall "IF" check succeeds making MFC think that the default printer has changed. This forces the Print dialog box to repopulate itself with the original default values.

This was not a problem in earlier 32-bit versions of MFC because there the port name was not checked.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in Windows NT version 3.51. This problem has been corrected in Windows NT Service Pack 4. For information on how to obtain it, please see the following article in the Microsoft Knowledge Base:

128465 How To Obtain Windows NT Version 3.51 U.S. Service Pack

There is no programmatic workaround in MFC. The user should select the printer properties button from the print dialog in order to set the paper orientation or any other settings.

<div class="moreinformation_section">

Sample Code
To recreate this problem, create an AppWizard-generated application, run it, and choose Print Setup from the File menu. Change the page orientation to landscape, and click OK. Bring up the Print Setup dialog box again, and notice that the orientation has been set back to portrait.

Additional query words: 4.00 4.10

Keywords: kbenv kboswinnt400sp4fix kbprb kbprint KB148891

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.