24-11-15, 12:55 PM
(آخر تعديل لهذه المشاركة : 24-11-15, 12:58 PM {2} بواسطة nabil.1710.)
(10-11-14, 11:13 PM)الوليد ☺ كتب :
السلام عليكم ورحمة الله
هذه دالة GetFormImage من مشروع أحد الأخوة، ترسل لها اسم الفورم واختيار بالإطار أم بدون، وأضفت لك طريقة استخدامها
PHP كود :
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' بالإطار '
GetFormImage(Me, True).Save("image.jpg", Imaging.ImageFormat.Jpeg)
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
' بدون الإطار '
GetFormImage(Me, False).Save("image.jpg", Imaging.ImageFormat.Jpeg)
End Sub
#Region "GetFormImage"
Private 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 System.Int32) As Boolean
Private Declare Auto Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As System.IntPtr) As System.IntPtr
Public Function GetFormImage(ByVal frm As Windows.Forms.Form, Optional ByVal withDecor As Boolean = True) As Drawing.Bitmap
Dim w As Integer = If(withDecor, frm.Width, frm.ClientSize.Width)
Dim h As Integer = If(withDecor, frm.Height, frm.ClientSize.Height)
Dim g As Drawing.Graphics = frm.CreateGraphics
Dim bmp As New Drawing.Bitmap(w, h, g)
Dim gr As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
Dim grhdc As IntPtr = gr.GetHdc
Dim frmhdc As IntPtr = If(withDecor, GetWindowDC(frm.Handle), g.GetHdc)
BitBlt(grhdc, 0, 0, w, h, frmhdc, 0, 0, &HCC0020)
gr.ReleaseHdc(grhdc)
If Not withDecor Then g.ReleaseHdc(frmhdc)
If frm.RightToLeft = RightToLeft.Yes And frm.RightToLeftLayout Then
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX)
End If
Return bmp
End Function
#End Region
End Class
السلام عليكم شكرا لك اخى الوليد على هذا الكود و نسأل الله ان يجعل هذا فى ميزان حسناتك : الكود يعمل جيدا و لكن عندى سؤال انا اريد التقاط اكثر من صورة و عندما اضغط للصورة الثانية يلغى ما قبلها اريد كود ترقيم الصورة تلقائى حتى لا يلغى ما قبلها و شكرا اخى على المساعدة
