Solved

How to catch the entire screen with MFC?

Posted on 2000-02-17
7
579 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
Comment Utility
Hi,

Just interested.....

VinExpert
0
 
LVL 1

Expert Comment

by:olgat
Comment Utility
May be this is some kind of help:

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

 
 
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 50 total points
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 30

Expert Comment

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

Author Comment

by:Andrian
Comment Utility
why doesn't it work (it just show the zip icon but not the entire screen)
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
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
Comment Utility
Thanks!it works without the clipboard staff.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 109
Expand macro to ask for filename column 8 34
Whole sheet autoscrub still needed 19 44
only14 challenge 19 63
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

16 Experts available now in Live!

Get 1:1 Help Now