2012-07-13 85 views
0

嗨,再次我的問題,這次它與這段代碼相關,即時通訊使用Visual Studio Beta 2012,我似乎無法找到問題,如果你們可以幫助我生病感激Vb.net PRTSC(屏幕截圖) - 錯誤

Public Class Form1 

    Private Sub fullScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fullScreen.Click 
     SendKeys.SendWait("^{PRTSC}") 
     Dim clip As IDataObject = Clipboard.GetDataObject() 
     If clip.GetDataPresent(GetType(System.Drawing.Bitmap)) Then 
      Dim screenCapture As Bitmap = CType(clip.GetData(GetType(System.Drawing.Bitmap)), Bitmap) 
      screenCapture.Save("C:\fullScreenCapture.bmp") 
     End If 
     Clipboard.Clear() 
    End Sub 
End Class 

錯誤:

A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll 

其他信息:錯誤genéricoEN GDI +。

如果有這種異常的處理程序,程序可能會安全地繼續。

回答

0

你可以採取截屏更輕鬆地使用以下(發送鍵時總是打在我的經驗小姐)

Private Function TakeScreenShot() As Bitmap 
    Dim scrn As Screen = Screen.FromControl(Me) 
    Dim screenSize As Size = New Size(scrn.Bounds.Width, scrn.Bounds.Height) 
    Dim screenGrab As New Bitmap(screenSize.Width, screenSize.Height) 
    Dim g As Graphics = Graphics.FromImage(screenGrab) 
    g.CopyFromScreen(New Point(scrn.Bounds.X, scrn.Bounds.Y), New Point(0, 0), screenSize) 
    Return screenGrab 
End Function 
+0

聰明,樂於助人ty :) – 2012-07-13 09:35:07