I want to simulate the ALT+PRINT SCREEN key exactly.
I have tried to over ride OnSysKeyDown and OnSysKeyUp. But this does
not seem to do it.
Please mail me at jgr...@onr.com if you can help, thanks alot.
I used this code once to create a bitmap of a screen rectangle.
You need to pass an lpRect that will represent the entire desktop so
try using GetDesktopWnd()->GetWindowRect() but I'm not sure about
that.
BOOL CMainFrame::GetScreenBitmap(LPRECT lpRect)
{
int nX, nY, nX2, nY2; // Coordinates of rectangle to grab
int xScrn, yScrn; // Screen resolution
CBitmap *pOldBitmap;
// Create the display dc
CDC DisplayDC;
DisplayDC.CreateDC("DISPLAY", NULL, NULL, NULL);
DisplayDC.SetMapMode(MM_TEXT);
CDC MemDC;
CBitmap ScreenBitmap;
MemDC.CreateCompatibleDC(&DisplayDC); // Create the memory DC
// Get points of rectangle to grab
nX = lpRect->left;
nY = lpRect->top;
nX2 = lpRect->right;
nY2 = lpRect->bottom;
// Get screen resolution
xScrn = DisplayDC.GetDeviceCaps(HORZRES);
yScrn = DisplayDC.GetDeviceCaps(VERTRES);
// Make sure bitmap rectangle is visible
if (nX < 0)
nX = 0;
if (nY < 0)
nY = 0;
if (nX2 > xScrn)
nX2 = xScrn;
if (nY2 > yScrn)
nY2 = yScrn;
// Create a bitmap compatible with the screen DC
ScreenBitmap.CreateCompatibleBitmap(&DisplayDC, nX2 - nX, nY2 - nY);
// Select new bitmap into memory DC
pOldBitmap = MemDC.SelectObject(&ScreenBitmap);
// bitblt screen DC to memory DC
MemDC.BitBlt(0, 0, nX2 - nX, nY2 - nY, &DisplayDC, nX, nY,SRCCOPY)
;
// Jason : Here is the place you copy ScreenBitmap to the clipboard
// Select old bitmap back into memory DC
MemDC.SelectObject(pOldBitmap);
return TRUE;
}
Hope this helps.
-Shami