all groups > dotnet drawing api > december 2005 >
You're in the

dotnet drawing api

group:

PrintPreviewControl not working on some machines



PrintPreviewControl not working on some machines jaredljensen NO[at]SPAM hotmail.com
12/29/2005 6:29:29 PM
dotnet drawing api: I have subclassed the PrintDocument class and overridden OnBeginPrint
and OnPrintPage to create a reusable class for reports. My app
displays these reports in a PrintPreviewControl. Everything works fine
on my XP Pro SP2 (Framework v2.0) dev machine.

The problem is that on some, but not all, machines (all XP) the
PrintPreviewControl will simply display "Document does not contain any
pages." I've verified that the BeginPrint and PrintPage events never
fire. However, if I display the document in a PrintPreviewDialog, it
works fine.

I've verified that one of the problem machines has a valid default
printer installed and that I can print to it. The only difference I
can think of is that the problem machine doesn't have SP2 installed.

Has anyone experienced this behavior?

TIA

Jared
Re: PrintPreviewControl not working on some machines jaredljensen NO[at]SPAM hotmail.com
12/30/2005 11:15:59 AM
Thanks Veikka. I searched the bug list and found 5 entries, none of
which described the same problem unfortunately.

Do you know if the PrintPreviewControl is supposed to work on a machine
with no printers installed? The PrintPreviewDialog works in this
scenario, but the PrintPreviewControl does not. I'm not sure if this
is by design or not.

Jared

[quoted text, click to view]
Re: PrintPreviewControl not working on some machines Andrew Smith (Infragistics)
12/30/2005 3:10:11 PM
I believe it needs a printer installed so that it can create the appropriate
device context upon which to base the dpi, etc. I don't see how the
printpreviewdialog would work when the printpreviewcontrol does not as the
printpreviewdialog contains a printpreviewcontrol that is used to generate
and display the preview pages. With regards to the problem, the
printpreviewcontrol initiates the print when it gets a paint message so its
possible that its trying to print before events can be raised. This could be
why it seems as though the printpreviewdialog is working while the
printpreviewcontrol is not. One thing that you might try is to call the
printpreviewcontrol's InvalidatePreview method - perhaps in the form load -
so that it will regenerate the preview.

[quoted text, click to view]

Re: PrintPreviewControl not working on some machines Jared
12/30/2005 4:10:40 PM
My bad. When no printers are installed, the PrintPreviewDialog throws
an exception, but the PrintPreviewControl does not. This is probably
by design, and the printer check must just be something you "get" with
PrintPreviewDialog.

Using InvalidatePreview() worked! Interestingly, I had tried Refresh()
without success.

Thanks so much for your help! Cheers!
Re: PrintPreviewControl not working on some machines Veikka
12/30/2005 5:22:34 PM
If I remember rigth, MSDN support pages contained some topics
considering error you described.

I'm not sure but I remembered that you should give a right parameter
to PrinterSettings ??? class that it would print at least one page.

Check it out from Support pages.

My problem couple weeks ago was that I could not print without
showing PrintDialog (there is a flag variable that should support this, but
I is a bug).


[quoted text, click to view]

AddThis Social Bookmark Button