I am using Visual Basic to get a screenshot of, in this case, the edit control in Notepad:
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)
This works fine, but as you keep typing, eventually you will get a scrollbar in the edit control. The above code only captures the visible area of the control. Is there a way to get the FULL control area as if there are no scrollbars? I am limited to Visual Basic and Win32 API obviously.