Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are doing it wrong. You should <em>not</em> customize printing settings by displaying the printer dialog and programmatically manipulating its controls. That's bound to go wrong, just like you've observed it does. This is not the expected use model for a common dialog.</p> <p>Instead, set default values for the <code>CPrintDialog</code> by modifying its <code>m_pd</code> structure, as described in <a href="http://msdn.microsoft.com/en-us/library/sk61115a.aspx">the documentation</a>:</p> <blockquote> <p>To use a <code>CPrintDialog</code> object, first create the object using the <code>CPrintDialog</code> constructor. Once the dialog box has been constructed, you can set or modify any values in the <code>m_pd</code> structure to initialize the values of the dialog box's controls. The <code>m_pd</code> structure is of type <a href="http://msdn.microsoft.com/en-us/library/ms646843.aspx"><code>PRINTDLG</code></a>. For more information on this structure, see the Windows SDK.</p> </blockquote> <p>You can also programmatically change the default printer for your entire application. This doesn't require showing any dialogs at all. To do this, call the <a href="http://msdn.microsoft.com/en-us/library/y5fkxh8d.aspx"><code>SelectPrinter</code></a> function. This sets a new printer and releases the previously-selected printer.</p> <p>Once you've done this, any time the print dialog is displayed, it will automatically show the specified printer as selected. And when you retrieve information about the selected printer, the information you will retrieve will apply to the correct printer.</p> <p>Find more information in this MSDN article: <a href="http://support.microsoft.com/kb/166129">How to programmatically print to a non-default printer in MFC</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload