Visual Basic 2008 - ScreenShot

Assalamualaikum....

ok..hari ini aku nak ajar korang buat Screenshot atau PrintScreen guna Visual Basic..
sebelum tu , klik link nie dulu..
KLIK SINI
barang yang diperlukan kat bawah nie..

1.Button [ 3 ]
2.PictureBox [ 1 ]
3.Form [ 2 ]

contoh ScreenShot aku punye..




kod untuk button1 nie...

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Hide()

        Dim area As Rectangle

        Dim capture As System.Drawing.Bitmap

        Dim graph As Graphics

        area = Form2.Bounds

        capture = New System.Drawing.Bitmap(Bounds.Width, Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)

        graph = Graphics.FromImage(capture)

        graph.CopyFromScreen(area.X, area.Y, 0, 0, area.Size, CopyPixelOperation.SourceCopy)

        PictureBox1.Image = capture
    End Sub

yang berwarna jaa..

kod untuk Button2...

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim save As New SaveFileDialog

        Try

            save.Title = "Save File"

            save.FileName = "Screenshot"

            save.Filter = "Png |*.Png"

            If save.ShowDialog() = DialogResult.OK Then

                PictureBox1.Image.Save(save.FileName, System.Drawing.Imaging.ImageFormat.Png)

            End If

        Catch ex As Exception

        End Try
    End Sub

kod untuk Button3..

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Form2.Show()
    End Sub
End Class

ok..korang mesti tak tau camne nak tambah Form yang kedua..
senang jerp..
korang pergi dekat 
" Project " ...
yang dekat atas tu..
lepas tu tekan " Add Windows Form "
haa..pastu jadilah Form yang kedua..
kalau tak paham , komen dekat bawah nie..
k..Assalamualaikum...

No comments on "Visual Basic 2008 - ScreenShot"

Leave a Reply