Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PrintDocument EndPrint event is not being called on cancel

Posted on 2011-02-19
2
Medium Priority
?
1,777 Views
Last Modified: 2013-11-12
When I call "Print" on the PrintDocument object and the user clicks "Cancel" on the printer setup dialog, the "EndPrint" event is not fired.  It only fires if the user proceeds with the printing (and the printing completes).  Does anyone have any idea why this might be happening?

Thanks,
Nicole
private Action _callback;

 public void Print(FrameworkElement elementToPrint, string Title, Action callback )
{

_callback = callback;

	PrintDocument pd = new PrintDocument();
	pd.EndPrint += new EventHandler<EndPrintEventArgs>(pd_EndPrint);
	pd.PrintPage += (o,e)=>
	{
		e.PageVisual = elementToPrint;
				
		e.HasMorePages = false;
	};
	pd.Print(Title);
			
}
void pd_EndPrint(object sender, EndPrintEventArgs e)
{
_callback();
}

Open in new window

0
Comment
Question by:nicolees
[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 Comments
 
LVL 4

Accepted Solution

by:
grishav earned 2000 total points
ID: 34936994
Hi,
This is "by design" (though I agree that it's not the best design I've seen):
From the documentation of EndPrint event on MSDN
(http://msdn.microsoft.com/en-us/library/system.windows.printing.printdocument.endprint(v=vs.95).aspx)


"The EndPrint event will not occur if the user cancels the print operation from the print dialog box."
So I don't think you can use this event to catch this.
0
 

Author Closing Comment

by:nicolees
ID: 34937704
Thanks for that info, I agree that is not ideal!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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