Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ALT+Print Screen question

0 views
Skip to first unread message

Jason Graham

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to

I was curious if anyone had the code or knows how to do a entire
screen capture to the clipboard.

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.


Shami Reshtik

unread,
Mar 13, 1997, 3:00:00 AM3/13/97
to

On Mon, 10 Mar 1997 23:55:44 GMT, jgr...@onr.com (Jason Graham)
wrote:

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

0 new messages