السلام عليكم
انصحك بالذهاب الى هذا المنتدى http://vbcity.com/forums/p/161428/690646.aspx
هذا هو الكود منقول من XTab ولكني غير مسئول عن صحته لاني لم اجربه
انصحك بالذهاب الى هذا المنتدى http://vbcity.com/forums/p/161428/690646.aspx
هذا هو الكود منقول من XTab ولكني غير مسئول عن صحته لاني لم اجربه
FriendWithEvents prntDoc AsNew PrintDocument()
Private Print_Image As Image
Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'print picture
Dim prnDialog As New PrintDialog()
'Get a Graphics Object from the form
Dim FormG As Graphics = Me.PictureBox1.CreateGraphics
'Create a bitmap from that graphics
Dim i As New Bitmap(Me.Width, Me.Height, FormG)
'Create a Graphics object in memory from that bitmap
Dim memG As Graphics = Graphics.FromImage(i)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = FormG.GetHdc
Dim HDC2 As IntPtr = memG.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, HDC1, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_Image = i.Clone()
'Clean Up
FormG.ReleaseHdc(HDC1)
memG.ReleaseHdc(HDC2)
FormG.Dispose()
memG.Dispose()
i.Dispose()
prnDialog.Document = prntDoc
' Optional Dialog:
'Dim r As DialogResult = prnDialog.ShowDialog
'If r = DialogResult.OK Then
prntDoc.Print()
'End If
End Sub
Private Sub prntDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prntDoc.PrintPage
e.Graphics.DrawImage(Print_Image, 0, 0)
End Sub
صاحب الرد عن السؤال هو Ged Mead (XTab)
ارجو ان يناسبكPrivate Print_Image As Image
Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'print picture
Dim prnDialog As New PrintDialog()
'Get a Graphics Object from the form
Dim FormG As Graphics = Me.PictureBox1.CreateGraphics
'Create a bitmap from that graphics
Dim i As New Bitmap(Me.Width, Me.Height, FormG)
'Create a Graphics object in memory from that bitmap
Dim memG As Graphics = Graphics.FromImage(i)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = FormG.GetHdc
Dim HDC2 As IntPtr = memG.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, HDC1, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_Image = i.Clone()
'Clean Up
FormG.ReleaseHdc(HDC1)
memG.ReleaseHdc(HDC2)
FormG.Dispose()
memG.Dispose()
i.Dispose()
prnDialog.Document = prntDoc
' Optional Dialog:
'Dim r As DialogResult = prnDialog.ShowDialog
'If r = DialogResult.OK Then
prntDoc.Print()
'End If
End Sub
Private Sub prntDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prntDoc.PrintPage
e.Graphics.DrawImage(Print_Image, 0, 0)
End Sub
صاحب الرد عن السؤال هو Ged Mead (XTab)
