Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Customizing a Print Dialog via PrintDlgEx in C++

Posted on 2013-02-05
4
Medium Priority
?
1,559 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
  • 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
This article is about my experience upgrading my consulting machine to Windows 10 Version 1709 (The Fall 2017 Creator Update)
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

971 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