printing a form with GDI+ stuff already on it
I've been printing a form with some lines drawn on it, and it prints fine, but when I print (or just preview) often times I get the "Generating Preview" dialog box as part of the bitmap that's generated before actually printing (or anything that's on top of the form, but nothing usually is since I bring the form to the front beforehand). I'm new to printing and I was looking if there was anyway to just disable that dialog with the PrintController class, but I didnt find anything. Here's the code I use:
VB Code:
PrintDocument1.PrintController = New System.Drawing.Printing.StandardPrintController
frmParent.Hide()
Me.BringToFront()
System.Windows.Forms.Application.DoEvents()
Dim imgToPrint As Image
Dim gFrmTemp As Graphics = Me.CreateGraphics()
Me.Refresh()
Dim bmap As New Bitmap(Me.Width, Me.Height, g)
Dim gTemp As Graphics = Graphics.FromImage(bmap)
Dim hdc1 As IntPtr = gFrmTemp.GetHdc
Dim hdc2 As IntPtr = gTemp.GetHdc
'get picture
BitBlt(hdc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, hdc1, 0, 0, 13369376)
'clone bitmap and dispose current one
imgToPrint = bmap.Clone()
'clean
gFrmTemp.ReleaseHdc(hdc1)
gTemp.ReleaseHdc(hdc2)
gFrmTemp.Dispose()
gTemp.Dispose()
bmap.Dispose()
'imgToPrint = GetControlBitmap(Me)
e.Graphics.DrawImage(imgToPrint, 0, 0)
imgToPrint.Dispose()
frmParent.Show()
...where BitBlt(...) is the method everyone seems to know.
I've tried the way in this thread but it seems that only generates bitmaps for controls (I tried passing it the form itself, but it doesnt pick up the GDI lines on the form, and I get a blank printout).
Is there anyway to hide this stupid dialog or to capture whats on the form for printing instead of a screenshot of the area the form occupies?