【问题标题】:Vb.net PRTSC (Screen capture) - ErrorVb.net PRTSC(屏幕截图) - 错误
【发布时间】:2012-07-13 08:08:15
【问题描述】:

您好,这次我的问题与这段代码有关,我使用的是 Visual Studio beta 2012,我似乎找不到问题,如果你们能帮助我,不胜感激

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

附加信息:GDI+ 中的一般错误。

如果有这个异常的处理程序,程序可以安全地继续。

【问题讨论】:

    标签: vb.net screen bmp take


    【解决方案1】:

    您可以使用以下方法更轻松地截屏(根据我的经验,发送键总是会被击中和错过)

    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
    

    【讨论】:

      【解决方案2】:

      您是否要捕获屏幕?为什么不使用 VS 的类来捕获屏幕?

      http://forum.codecall.net/topic/51761-creating-a-screen-shot-tool-vbnet

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-08-11
        • 2011-02-03
        • 2015-07-07
        • 1970-01-01
        • 2016-07-08
        • 2010-11-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多