A StartDocPrinter call was not issued

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a customer who has reported that they get the following "intermittent" error":<br/>
A StartDocPrinter call was not issued
They have 2 Windows 7 machines and one XP machine all printing to the same Xerox WorkCentre 7532 PCL6 printer. The XP machine never gets the error while on the Win 7 machines, sometimes it works and sometimes it does not!
I have included a stack trace and the actual code.<br/>
Anybody with any ideas?
Thanks in advance,<br/>
Terry L.
PS. The timer stuff is what I am doing to get the "drop downs" off the form before capturing the image.
--------------------Stack Trace -----------------------<br/>
System.ComponentModel.Win32Exception: A StartDocPrinter call was not issued<br/>
at System.Drawing.Printing.StandardPrintController.OnEndPrint(PrintDocument document, PrintEventArgs e)<br/>
at System.Windows.Forms.PrintControllerWithStatusDialog.OnEndPrint(PrintDocument document, PrintEventArgs e)<br/>
at System.Drawing.Printing.PrintController.Print(PrintDocument document)<br/>
at System.Drawing.Printing.PrintDocument.Print()<br/>
at gpi.PayBreezeII.PayBreeze.OnPrintform(Object s, EventArgs e)<br/>
at System.Windows.Forms.Timer.OnTick(EventArgs e)<br/>
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)<br/>
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
-------------------- Actual Code ----------------------<br/>
Dim memoryImage As Bitmap<br/>
Dim t As New Timer
print form from split button<br/>
Private Sub FormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintFormToolStripMenuItem.Click<br/>
PrintToolStripSplitButton.HideDropDown()<br/>
t.Interval = 10<br/>
AddHandler t.Tick, AddressOf OnPrintform<br/>
t.Start()<br/>
End Sub
print form from file menu<br/>
Private Sub FormFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintFormFileToolStripMenuItem.Click<br/>
FileToolStripMenuItem.HideDropDown()<br/>
t.Interval = 10<br/>
AddHandler t.Tick, AddressOf OnPrintform<br/>
t.Start()<br/>
End Sub
Private Sub OnPrintform(ByVal s As Object, ByVal e As System.EventArgs)<br/>
t.Stop()<br/>
RemoveHandler t.Tick, AddressOf OnPrintform<br/>
CaptureScreen()<br/>
PrintDialog1.Document = FormPrintDocument<br/>
FormPrintDocument.Print()<br/>
End Sub
Private Sub CaptureScreen()<br/>
Dim myGraphics As Graphics = Me.CreateGraphics()<br/>
Dim s As Size = Me.Size<br/>
memoryImage = New Bitmap(s.Width, s.Height, myGraphics)<br/>
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)<br/>
memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)<br/>
End Sub
Private Sub FormPrintDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles FormPrintDocument.PrintPage<br/>
e.Graphics.DrawImage(memoryImage, e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)<br/>
End Sub
<hr class="sig Terry

View the full article
 
Back
Top