H
Hotrod2000
I'am trying to print a windows form with the following code, but keep
getting this error message (posted below code).
My form has a few unused labels on in and a print button (Button1)
Any help would be greatly appreiciated :-
Public Class Form1
Private WithEvents pd As Printing.PrintDocument
Dim formImage As Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" Alias
"BitBlt" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal
nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer,
ByVal hdcScr As IntPtr, ByVal nXSrc As Integer, ByVal NySrc As
Integer, ByVal dwRop As System.Int32) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
pd = New Printing.PrintDocument
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
e.Graphics.DrawImage(formImage, 100, 100)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
GetFormImage()
pd.Print()
End Sub
Private Sub GetFormImage()
Dim g As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
formImage = New Bitmap(s.Width, s.Height, g)
Dim mg As Graphics = Graphics.FromImage(formImage)
Dim dc1 As IntPtr = g.GetHdc
Dim dc2 As IntPtr = mg.GetHdc
Dim widthDiff As Integer = (Me.Width -
Me.ClientRectangle.Width)
Dim heightDiff As Integer = (Me.Height -
Me.ClientRectangle.Height)
Dim borderSize As Integer = widthDiff \ 2
Dim heightTitleBar As Integer = heightDiff - borderSize
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width + widthDiff, dc1, 0
- borderSize, 0 - heightTitleBar, 13369376)
g.ReleaseHdc(dc1)
mg.ReleaseHdc(dc2)
End Sub
End Class
The error I get is this :-
Argument not specified for parameter 'dwRop' of 'Declare Ansi Function
BitBlt Lib "gdi32.dll" Alias "BitBlt" (hdcDest As System.IntPtr,
nXDest As Integer, nYDest As Integer, nWidth As Integer, nHeight As
Integer, hdcScr As System.IntPtr, nXSrc As Integer, NySrc As Integer,
dwRop As Integer) As Long'.
Thanks in anticipation.
P
getting this error message (posted below code).
My form has a few unused labels on in and a print button (Button1)
Any help would be greatly appreiciated :-
Public Class Form1
Private WithEvents pd As Printing.PrintDocument
Dim formImage As Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" Alias
"BitBlt" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal
nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer,
ByVal hdcScr As IntPtr, ByVal nXSrc As Integer, ByVal NySrc As
Integer, ByVal dwRop As System.Int32) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
pd = New Printing.PrintDocument
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
e.Graphics.DrawImage(formImage, 100, 100)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
GetFormImage()
pd.Print()
End Sub
Private Sub GetFormImage()
Dim g As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
formImage = New Bitmap(s.Width, s.Height, g)
Dim mg As Graphics = Graphics.FromImage(formImage)
Dim dc1 As IntPtr = g.GetHdc
Dim dc2 As IntPtr = mg.GetHdc
Dim widthDiff As Integer = (Me.Width -
Me.ClientRectangle.Width)
Dim heightDiff As Integer = (Me.Height -
Me.ClientRectangle.Height)
Dim borderSize As Integer = widthDiff \ 2
Dim heightTitleBar As Integer = heightDiff - borderSize
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width + widthDiff, dc1, 0
- borderSize, 0 - heightTitleBar, 13369376)
g.ReleaseHdc(dc1)
mg.ReleaseHdc(dc2)
End Sub
End Class
The error I get is this :-
Argument not specified for parameter 'dwRop' of 'Declare Ansi Function
BitBlt Lib "gdi32.dll" Alias "BitBlt" (hdcDest As System.IntPtr,
nXDest As Integer, nYDest As Integer, nWidth As Integer, nHeight As
Integer, hdcScr As System.IntPtr, nXSrc As Integer, NySrc As Integer,
dwRop As Integer) As Long'.
Thanks in anticipation.
P