Donnerstag, 23. September 2010

The Windows 7 Printing Bug

Of course I do not know if it is a bug. But internal we call it so. We learned about it some month ago. A customer uses our DOT.NET based software WWS-LITE Win for stock and inventory and claimed he is not able to print the article lists...

Of course we are a bit confused. Our article list is saved in a DataGridView table. With a small printing sub we send the content of the table to the printer by using the DOT.NET printerdialog.

First very well known action of the printerdialog is to open the printer window to let the user choose between the installed printer. But this fails. There is no printer window under Windows7. It works under Windows XP - but fails under Windows 7 64bit Home Edition.

The solution: UseEXDialog

We learned there is a UseEXDialog member inside printerdialog and we never used it before. In our Visual Studio 2005 Prof. Version the UseEXDialog member undocumented. (Undocumented means: there is no text what should happen if we use the member.) So we never thought about using it and all the software before worked without using it.

But we learned another thing too. It is important to set the member at TRUE. With this small change the software still opens the printer window and all runs completly under Windows 7 64bit. Heureka!

OK - here is the sample which works in our environment.

        Dim prt1 As New PrintDialog
        With prt1
            .AllowSelection = True
            .AllowPrintToFile = False        'TRUE führt zu Absturz!
            .AllowCurrentPage = False
            .AllowSelection = False
            .Document = Me.PrintDocument1
            .UseEXDialog = True
        End With

Of course we are updating all our software packages to make them printable under Windows 7 64bit...

Keine Kommentare:

Kommentar veröffentlichen