Windows Develop Bookmark and Share   
 index > Windows Forms General > Detecting if preview mode
 

Detecting if preview mode

Hi,

When I use the System.Windows.Forms.PrintPreviewDialog and get a PrintPage event. How can I see the difference between painting to the screen (in preview mode) or if painting to a printer (e.g. the user has pressed the Print button the PrintPreviewDialog).

Thanks in advance for any help!
MigrationUser 1  Wednesday, January 21, 2004 8:25 AM
Interesting question! I thought it would be simple, but couldn't find any way to do it. 

Here's a simple solution: Create your own print preview dialog using the PrintPreview control. It's easy to do. Then, you can track when users click the Print button on the form, so your code can definitely know when they're really printing (vs. previewing on the screen).

Love to hear if there's a reasonable way to do this using the PrintPreviewDialog control. I still feel that there is, and that we're just missing it.
MigrationUser 1  Thursday, January 29, 2004 6:39 PM
Yea. The only solution I found was to track it myself. I'm using Chris Sells good code to get the RealMarginBounds (from his book). Because of the dpi difference the code needs to know if it's in preview mode.

Thanks for your help Ken, but I got the same impression as you got. There probably is some very simple hack around this.

MigrationUser 1  Friday, January 30, 2004 7:14 AM
I'll have to check out Chris' code. I've been using the code in Charles Petzold's book to calculate the real margins. Hope they fix this in the framework next time...
MigrationUser 1  Saturday, February 07, 2004 7:21 PM
how do you track if the user clicked the print button on the printpreviewdialog control ?
MigrationUser 1  Wednesday, February 18, 2004 2:49 PM

You can use google to search for other answers

Custom Search

More Threads

• Creating Custom Textbox Control .NET 2005
• Added an existing user control to project, cannot view designer
• Windows Picture and Fax Viewer
• AxHost & VBControlExtender
• How to get a listing of printers?
• Adding SplashScreen Item
• Removing controls from a Panel within code
• Filtering Parent row values based upon existing child value
• How to use domain user instead of database user in vb.net windows form authonitication?
• Complicated Custom DataGridView Question with example.