Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • Last Modified:

How to catch the entire screen with MFC?

I want to catch the entire screen like "print screen" but by code.
need help!
0
Andrian
Asked:
Andrian
1 Solution
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

Just interested.....

VinExpert
0
 
olgatCommented:
May be this is some kind of help:

MDSN ID: Q59380
How to Do a Print Screen Within a Program

 
 
0
 
ZoppoCommented:
Hi Andrian,

This code copies entire screen to clipboard:

/***********/
// copy desktop window's content to a CBitmap
CWnd* pWnd = GetDesktopWindow();
CRect rect;
pWnd->GetWindowRect( rect );
CDC* pDC = pWnd->GetDC();
CDC memDC;
memDC.CreateCompatibleDC( pDC );
CBitmap bmp;
bmp.CreateCompatibleBitmap( pDC, rect.Width(), rect.Height() );
CBitmap* pOldBmp = memDC.SelectObject( &bmp );
memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY );
memDC.SelectObject( pOldBmp );
memDC.DeleteDC();
// copy bitmap to clipboard
OpenClipboard();
EmptyClipboard();
SetClipboardData( CF_BITMAP, (HBITMAP)bmp);//Detach() );
CloseClipboard();
/***********/

BTW, olgat, this site describes printing for 16bit DOS app's ...

hope that helps,

ZOPPO
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ZoppoCommented:
excuse me for this //Detach();, just an artefact from testing    :)
0
 
AndrianAuthor Commented:
why doesn't it work (it just show the zip icon but not the entire screen)
0
 
ZoppoCommented:
I'm not sure ... given code works on my system (WinNT4) ... perhaps try it without the clipboard stuff, just bitblt the memory dc's content to a window...
0
 
AndrianAuthor Commented:
Thanks!it works without the clipboard staff.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now