hMDC = CreateCompatibleDC(hDC) sw = Screen.PrimaryScreen.Bounds.Width sh = Screen.PrimaryScreen.Bounds.Height hBMP = CreateCompatibleBitmap(hDC, sw, sh) hBMPOld = SelectObject(hMDC, hBMP) BitBlt(hMDC, 0, 0, sw, sh, hDC, 0, 0, SRCCOPY) hBMP = SelectObject(hMDC, hBMPOld) PictureBox1.Image = Image.FromHbitmap(New IntPtr(hBMP)) DeleteDC(hDC) DeleteDC(hMDC) DeleteObject(hBMP) Me.Button2.Enabled = True End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Button2.Enabled = False End Sub Dim ofd As New SaveFileDialog Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ofd.Filter = "jpg file|*.jpg|bmp file|*.bmp" Dim bmp As Bitmap = Me.PictureBox1.Image If ofd.ShowDialog = DialogResult.OK Then bmp.Save(ofd.FileName) End If End Sub End Class |