printer and PrintDocument class

  • Thread starter Thread starter Cheung
  • Start date Start date
C

Cheung

Guest
Hi all,
I encountered the following problem:
When I previewed/printed a document using the following code, it worked fine when my default printer is a laser printer. However, it threw an exception when my default printer was set to a dot matrix printer "Epson LQ-850". I used the following code:

Public Function PreviewFunction( ....... ) As Boolean

........................

myPrintDocu = New PrintDocument()
myPreviewDocu = New PrintPreviewDialog()
Try
AddHandler myPrintDocu.PrintPage, AddressOf PrintText
myPrintDocu.DefaultPageSettings = printPageSettings
myPreviewDocu.Document = myPrintDocu
msgbox(" it is now here!!!")
myPreviewDocu.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function

public Function PrintText(ByVal sender As Object, ByVal e As PrintPageEventArgs)
msgbox("it is now inside PrintText")
.............................

End Function

When the printer was the dot matrix one and when the previewFunction was called, the message "it is now here!!!" was printed. After that, an exception was thrown and the msgbox in the PrintText function didnt reach.
If you know what happened, can you pls let me know.

Thank you.
 
wrong question...

I found that the problem was not due to the printers. It was due to the platforms. I wrote the program on NT. and when I ran this on a Win98 (of course with dotframework installed), the exception threw. any idea?

Thanks and Regards.
 
Back
Top