Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>NOTE</strong>: this is a rewrite of an earlier question.</p> <p>The way Windows/GDI+ printing works is that it uses a <code>PrintDialog</code> to obtain a printer identifier (and to also let the user know what printer they are printing to). So in order to have silent printing, you need to obtain a printer identifier without showing a dialog.</p> <p>So <strong><em>REMOVE</em></strong> this code:</p> <pre><code>// Open a printing dialog to fetch the HDC of the desired printer. PRINTDLG dialog; ZeroMemory(&amp;dialog, sizeof(PRINTDLG)); dialog.lStructSize = sizeof(PRINTDLG); dialog.Flags = PD_PRINTSETUP | PD_RETURNDC; BOOL dialogResult = ::PrintDlg(&amp;dialog); if (!dialogResult) // Error or cancel. { DWORD reason = CommDlgExtendedError(); if (!reason) // User cancelled. return S_OK; logger-&gt;Error("Could not print page, dialog error code: %i", reason); return E_FAIL; } HDC hdc = dialog.hDC; </code></pre> <p>And then replace the last line (<code>HDC hdc = ...</code>) with some other way of getting a printer HDC. You could use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd144876%28v=vs.85%29.aspx" rel="nofollow"><code>GetDefaultPrinter()</code></a> to get the name of the default printer, and then get a HDC using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd183490%28v=vs.85%29.aspx" rel="nofollow"><code>CreateDC()</code></a>. </p> <p>Optionally, you could select a printer or create a custom print dialog using the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162692%28v=vs.85%29.aspx" rel="nofollow"><code>EnumPrinters()</code></a> function.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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