Solved

How to catch the entire screen with MFC?

Posted on 2000-02-17
7
582 Views
Last Modified: 2013-11-20
I want to catch the entire screen like "print screen" but by code.
need help!
0
Comment
Question by:Andrian
7 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 2530769
Hi,

Just interested.....

VinExpert
0
 
LVL 1

Expert Comment

by:olgat
ID: 2530895
May be this is some kind of help:

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

 
 
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 50 total points
ID: 2530912
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 31

Expert Comment

by:Zoppo
ID: 2530919
excuse me for this //Detach();, just an artefact from testing    :)
0
 

Author Comment

by:Andrian
ID: 2541578
why doesn't it work (it just show the zip icon but not the entire screen)
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2541694
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
 

Author Comment

by:Andrian
ID: 2544936
Thanks!it works without the clipboard staff.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 77
move a line in eclipse 3 81
scoreUp challenge 14 57
Updating statistics with error notification email in SQL server 4 73
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now