Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft VC .NET
Printing a form with VB.Net
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Hotrod2000, post: 13868674"] 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 [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft VC .NET
Printing a form with VB.Net
Top