PRB: CommonDialog Changes System Wide Printer Properties (198712)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 4.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
This article was previously published under Q198712 SYMPTOMS
When you use the Printer CommonDialog control from a Visual Basic application under Microsoft Windows 95 or Microsoft Windows 98, changes that are made may be shared with other applications. If you look at the properties of the printer that is being used, it may also reflect your selections. This can include, but is not limited to, attributes such as Copies, PaperSize, Default Source, Duplex, and Orientation.
CAUSE
The common dialog itself does not normally effect global default settings.
However, the implementation in the Visual Basic common dialog control does. This is how changes made in the dialog are made known to the Printer object, which reads the new global default settings.
NOTE: With Microsoft Windows NT-based platforms, this is not a problem. Windows NT security features prevent the common dialog control from changing the printer's global default settings. This also means that the Printer object is not updated with the user's selections in the Common Dialog. The one change that can be made is the Default Printer because this is a user preference. To prevent this, you can set the PrinterDefault property to False before you call the ShowPrinter method. For additional information, see the article cross-reference in the "References" section of this article.
RESOLUTION
To work around this behavior, use one of the following methods to substitute another dialog box for the printer common dialog:
- Use the Win32 API function PrintDlg or PageSetupDlg to open a printer dialog box. Changes that are made through this dialog box are stored in a DEVMODE structure. These settings can then be assigned directly to the Printer object's properties. The article in the "References" section of this article includes a sample DLL that uses the PrintDlg function for this purpose.
- Create and use your own dialog box rather than the CommonDialog control. The changes that are made through this dialog box can then be assigned directly to the Printer object's properties.
STATUS
This behavior is by design.
REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
173981 PRB: Behavior Differences of Print Dialog Box on Different Platforms
NOTE: This article includes an example of the first workaround.
MSDN Library CD
WIN32 Software Development Kit (SDK) Programmer's Guide, search on: "DEVMODE".
Modification Type: | Major | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kbCmnDlg kbCmnDlgPrint kbprb KB198712 |
---|
|