Untuk Membuat Screen Capture Menggunakan Visual Basic 2008/ VB.net yang dibutuhkan adalah:
- 2 button
- 1 picturebox
- 2 form
Ganti backgroun button1 dengan gabar foto apa saja, dan button 2 dengan gambar disket dan ganti background form1 dengan gabar sesuai selera anda saja lihat gambar dibawah ini:
Pada Form2 taruhlah 1 Button dengan backgorund kamera, dan FormBorderStyle ganti menjadi FixedDialog, ControlBox False dan ganti background menjadi warna biru seperti gambar dibawah ini:
Langkah selanjutnya adalah masuk ke halaman form1, klik 2 kali ditengah form, hapus semua kode yang ada dan masukkan kode dibawah:
Kemudian pada Form2 klik 2 kali, hapus semua kode yang ada lalu masukkan kode dibawah:Public Class Form1
Dim sv As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sv.Filter = "JPG File|*.jpg"
If sv.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(sv.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
Else
End If
End Sub
Private Sub Button_StartMouseSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_StartMouseSelect.Click
Form2.StartPosition = FormStartPosition.CenterScreen
Form2.Opacity = 30
Form2.Show()
Me.Hide()
End Sub
Private Sub Form1_MaximumSizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MaximumSizeChanged
End Sub
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If Me.WindowState = FormWindowState.Maximized Then
PictureBox1.Height = 648
ElseIf Me.WindowState = FormWindowState.Normal Then
PictureBox1.Height = 404
ElseIf Me.WindowState = FormWindowState.Minimized Then
PictureBox1.Height = 404
End If
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Location = New Point(MousePosition.X, MousePosition.Y)
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.SizableToolWindow
Me.BackColor = Color.Blue
Me.TransparencyKey = Color.Blue
Me.TopMost = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Opacity = 0
Dim area As Rectangle = Me.Bounds
Dim capture As System.Drawing.Bitmap = New System.Drawing.Bitmap(Bounds.Width, Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim graph As Graphics = Graphics.FromImage(capture)
graph.CopyFromScreen(area.X, area.Y, 0, 0, area.Size, CopyPixelOperation.SourceCopy)
Form1.PictureBox1.Image = capture
Form1.Show()
Me.Hide()
End Sub
End Class
0 comments:
Speak up your mind
Tell us what you're thinking... !