How to handle PRINT Button of PrintPreviewDialog (ugent)

jerry_hokh

Active member
Joined
Mar 14, 2006
Messages
25
Programming Experience
1-3
Hi all.
It's would be appreciated if any one can help me on this:
I want when I press Print button on the menu bar of the PrintPreviewDialog it also do some other things for me..

thank you very much in advanced.

Jerry.
 
I think JohnH may have missed what you're actually asking. Are you saying that you want to display a PrintPreviewDialog and then when the user presses the Print button on that dialogue it will perfrom some action specified by you and then print? If so then there is no in-built mechanism to do this. You would have two options. You could create your own form to use as a print preview and place a PrintPreviewControl on that. That way you can make it behave any way you want. The other option is a little bit kludgy but will work. When you press that Print button it will execute your printing code exactly as though you had just called Print on your PrintDocument directly. What you could do is declare a Boolean variable that indicates that you have called Print on the PrintDocument. You set that variable just before you call Print. In the PrintPage event handler you test that variable and if it is True then you know that no preview was used. If it is False then a preview was used and you need to perform your additional actions. You would then set the variable back to False regardless at the end of your printing routine.
 
Yes, I missed the 'also', thinking the question was to do something instead of printing, when it was about doing something in addition. Good spotted. A boolean and using the PrintDocument events should do.
 
Back
Top