我正在使用Visual Basic获取截图,在本例中是记事本中的编辑控件:
Dim windowHandle = FindWindow("Notepad", Nothing)
windowHandle = FindWindowEx(windowHandle, Nothing, "Edit", Nothing)
Dim clientRect As RECT
GetClientRect(windowHandle, clientRect)
Dim windowDeviceContext = GetDC(windowHandle)
Dim memoryDeviceContext = CreateCompatibleDC(windowDeviceContext)
Dim bitmapHandle = CreateCompatibleBitmap(windowDeviceContext, clientRect.Right, clientRect.Bottom)
Dim selectObjectResult = SelectObject(memoryDeviceContext, bitmapHandle)
Dim bitBltResult = BitBlt(memoryDeviceContext, 0, 0, clientRect.Right, clientRect.Bottom, windowDeviceContext, 0, 0, TernaryRasterOperations.SRCCOPY)
Dim bmpScreen As Bitmap = Bitmap.FromHbitmap(bitmapHandle)
bmpScreen.Save(Filepath)
这样可以正常工作,但是当您继续输入时,最终您将在编辑控件中获得一个滚动条。上面的代码仅捕获控件的可见区域。有没有办法让FULL控制区好像没有滚动条?我显然仅限于Visual Basic和Win32 API。