Solved

Customizing a Print Dialog via PrintDlgEx in C++

Posted on 2013-02-05
4
1,468 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

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

710 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