You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.3 KiB
70 lines
2.3 KiB
Imports System.Drawing
|
|
Public Class form1
|
|
|
|
|
|
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 Const SRCCOPY As Integer = &HCC0020
|
|
|
|
|
|
Dim r As New System.Drawing.Rectangle
|
|
Dim p As New Point
|
|
Dim p2 As New Point
|
|
Dim t As Rectangle
|
|
|
|
Private Sub TSBtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBtnDelete.Click
|
|
saveasbitmap(Me.C1Kontakte)
|
|
t.Y = Me.MenuStrip1.Top
|
|
t.X = Me.MenuStrip1.Left
|
|
t.Width = Me.MenuStrip1.Width
|
|
t.Height = Me.MenuStrip1.Height
|
|
|
|
Dim b As New Bitmap(t.Width, t.Height)
|
|
Me.DrawToBitmap(b, t)
|
|
b.Save("c:\temp\menustrip1.bmp")
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Function GetFormImage() As Bitmap
|
|
' Get this form's Graphics object.
|
|
Dim me_gr As Graphics = Me.CreateGraphics
|
|
|
|
' Make a Bitmap to hold the image.
|
|
Dim bm As New Bitmap(Me.Width, _
|
|
Me.Height, me_gr)
|
|
Dim bm_gr As Graphics = me_gr.FromImage(bm)
|
|
Dim bm_hdc As IntPtr = bm_gr.GetHdc
|
|
|
|
' Get the form's hDC. We must do this after
|
|
' creating the new Bitmap, which uses me_gr.
|
|
Dim me_hdc As IntPtr = me_gr.GetHdc
|
|
|
|
' BitBlt the form's image onto the Bitmap.
|
|
BitBlt(bm_hdc, 0, 0, Me.Width, _
|
|
Me.Height, _
|
|
me_hdc, 0, 0, SRCCOPY)
|
|
me_gr.ReleaseHdc(me_hdc)
|
|
bm_gr.ReleaseHdc(bm_hdc)
|
|
|
|
' Return the result.
|
|
Return bm
|
|
End Function
|
|
|
|
Public Function saveasbitmap(ByRef ctl As Control)
|
|
Dim g As Graphics = ctl.CreateGraphics
|
|
Dim b As New Bitmap(ctl.Width, ctl.Height)
|
|
ctl.DrawToBitmap(b, New Rectangle(0, 0, ctl.Width, ctl.Height))
|
|
b.Save("c:\temp\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
|
|
End Function
|
|
|
|
Private Sub TSBtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBtnSave.Click
|
|
Dim bm As Bitmap = GetFormImage()
|
|
bm.Save("c:\temp\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
|
|
End Sub
|
|
End Class |