Solved

Customizing a Print Dialog via PrintDlgEx in C++

Posted on 2013-02-05
4
1,492 Views
Last Modified: 2016-11-01
I need to customize a Print Dialog via PrintDlgEX in C++ (no MFC, no .NET).

I currently support printing from a PrintDlg dialog that is not customized.

PrintDlgEX dialogs add fields I don't want to see (Page Range and Collate for example).  I also want to add a couple of fields that are unique to my application as well as adding Portrait and Landscape onto the dialog similar to the PrintDlg.
I've found the definition of PrintDlgEx:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646942(v=vs.85).aspx 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646844(v=vs.85).aspx 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646896(v=vs.85).aspx

What I know so far:
I have code working that will bring up the PrintDlgEX dialog.

I understand I have to create an instance of a callback class that implements the IPrintDialogCallback interface and connect it to lpCallback field.  This class needs to define HandleMessage, InitDone and SelectionChange methods.

I understanding I need to create a dialog in my .rsc file that defines the lower portion of the print dialog. This has to be linked to the lpPrintTemplateName.   I’ve found the PrnSetup.dlg file that has the default fields for this dialog.

What I'm after:
The absolute perfect solution would be to find a C++ example/sample app of the PrintDlgEX that shows a customized version of the dialog.  You would think Microsoft would have this somewhere but I haven't found it with quite a bit of searching.  I’m not looking for anything fancy, just enough to show how everything is connected.

If no sample is available any good books, documentation or sites that would explain the overall process and what needs to go in the callback functions would be helpful.

Any help is appreciated.

Mike
0
Comment
Question by:mlazear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
mlazear earned 0 total points
ID: 38911642
I'll be closing this issue since there has been no response and after many hours of searching I have found enough info to get me started.

I don't have a sample app to post but here are some of the pieces of info I found:

Sample printing apps - I don't think these did any customizations but it's a place to start
http://archive.msdn.microsoft.com/WindowsPrintSample 

When using a customization (template) on the print dialog you have to set a number of variables within the PrintDlgEX structure.

Flags must include the PD_ENABLEPRINTTEMPLATE flag

lpPrintTemplateName must point to your customized dialog and will look something like this: pPDX->lpPrintTemplateName = MAKEINTRESOURCE(IDD_PRINTCUSTOMIZED);

lpCallback will need to point to the custom class that supports the IPrintDialogCallback interface and will look something like:
pPDX->lpCallback = new CDevMgrPrintDialogCallback();

Each method in the iPrintDialogCallback will need to be implemented.  The best description of what has to go in these methods (InitDone, SelectionChange, HandleMessage) I found in the the CommDlg.h file:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\CommDlg.h

In that same folder is PrnSetup.Dlg
At the bottom of the file is PRINTDLGEXORD which is the default template for the PrintDlgEX dialog.  I copied it into my code and then tweaked the fields as necessary for the customization I wanted to create.

Hopefully this fills in the blanks for someone looking for the same info I was.
0
 

Author Closing Comment

by:mlazear
ID: 38911649
My answer doesn't really deserve an A but since I'm providing answers for my own question I'm not going to give me a low grade.
0
 

Expert Comment

by:Ron Francis
ID: 41869552
Did you ever get it working?
I'm trying to do the same thing and finding very little information as to how to go about it anywhere.
I have what I thought should work, but whenever I access my custom controls, I get often get random unhandled exceptions.
It's driving me crazy.

Anyway, I'm hoping you're still around and can shed some light on how you implemented it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question