brickbuilder
New Member
- Joined
- Apr 10, 2015
- Messages
- 30
Hello, I have this useful little function written in C++ a couple years ago which takes an x,y point on the screen and extends a rectangle based on width/height (w,h) to take a screenshot of a specified rectangle of the desktop screen.
I'm really hoping that somebody around here might know a bit about how to convert this function to a VBA equivalent.
Thanks!!!!!!!!!!!!!!!!!!!!
I'm really hoping that somebody around here might know a bit about how to convert this function to a VBA equivalent.
Thanks!!!!!!!!!!!!!!!!!!!!
Code:
ScreenCapture(int x, int y, int w, int h, LPCSTR fname){
HDC hdcSource = GetDC(NULL);
HDC hdcMemory = CreateCompatibleDC(hdcSource);
int capX = GetDeviceCaps(hdcSource, HORZRES);
int capY = GetDeviceCaps(hdcSource, VERTRES);
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSource, w, h);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);
BitBlt(hdcMemory, 0, 0, w, h, hdcSource, x, y, SRCCOPY);
hBitmap = (HBITMAP)SelectObject(hdcMemory, hBitmapOld);
DeleteDC(hdcSource);
DeleteDC(hdcMemory);
HPALETTE hpal = NULL;
if (SaveBitmap(fname, hBitmap, hpal)) 'separate saving function
return true;
return false;
}