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:
  1. PrintDocument1.PrintController = New System.Drawing.Printing.StandardPrintController
  2.  
  3.         frmParent.Hide()
  4.         Me.BringToFront()
  5.         System.Windows.Forms.Application.DoEvents()
  6.  
  7.         Dim imgToPrint As Image
  8.         Dim gFrmTemp As Graphics = Me.CreateGraphics()
  9.  
  10.         Me.Refresh()
  11.  
  12.         Dim bmap As New Bitmap(Me.Width, Me.Height, g)
  13.         Dim gTemp As Graphics = Graphics.FromImage(bmap)
  14.  
  15.         Dim hdc1 As IntPtr = gFrmTemp.GetHdc
  16.         Dim hdc2 As IntPtr = gTemp.GetHdc
  17.  
  18.         'get picture
  19.         BitBlt(hdc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, hdc1, 0, 0, 13369376)
  20.  
  21.         'clone bitmap and dispose current one
  22.         imgToPrint = bmap.Clone()
  23.  
  24.         'clean
  25.         gFrmTemp.ReleaseHdc(hdc1)
  26.         gTemp.ReleaseHdc(hdc2)
  27.         gFrmTemp.Dispose()
  28.         gTemp.Dispose()
  29.         bmap.Dispose()
  30.         'imgToPrint = GetControlBitmap(Me)
  31.  
  32.         e.Graphics.DrawImage(imgToPrint, 0, 0)
  33.  
  34.         imgToPrint.Dispose()
  35.  
  36.         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?