VB如何抓取指定屏幕区域。
谢谢

解决方案 »

  1.   

    StretchBltPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Sub Command1_Click()
    Dim wS As Long, hS As Long, w As Long, h As Long
    Picture1.Cls
    Picture1.ScaleMode = vbPixels
    wS = Screen.Width \ Screen.TwipsPerPixelX
    hS = Screen.Height \ Screen.TwipsPerPixelY
    w = Picture1.ScaleWidth
    h = Picture1.ScaleHeight
    StretchBlt Picture1.hdc, 0, 0, w, h, GetDC(0), 0, 0, wS, hS, vbSrcCopy
    ReleaseDC Picture1.hwnd, GetDC(0)
    End Sub