Click here to Skip to main content
15,891,529 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: FormatMessage Error : ERROR_MR_MID_NOT_FOUND Pin
Ghazi H. Wadi12-Jan-01 11:43
Ghazi H. Wadi12-Jan-01 11:43 
GeneralRe: FormatMessage Error : ERROR_MR_MID_NOT_FOUND Pin
tatazou15-Jan-01 4:15
tatazou15-Jan-01 4:15 
QuestionHow to detect when the view is finished resizing Pin
12-Jan-01 4:18
suss12-Jan-01 4:18 
AnswerRe: How to detect when the view is finished resizing Pin
NormDroid12-Jan-01 4:38
professionalNormDroid12-Jan-01 4:38 
GeneralSelect a pen color Pin
.::RockNix::.12-Jan-01 3:23
.::RockNix::.12-Jan-01 3:23 
GeneralRe: Select a pen color Pin
David Fedolfi12-Jan-01 8:20
David Fedolfi12-Jan-01 8:20 
GeneralRe: Select a pen color Pin
.::RockNix::.15-Jan-01 1:19
.::RockNix::.15-Jan-01 1:19 
GeneralPlease tell me what's wrong in here... Pin
Jason Troitsky12-Jan-01 1:19
Jason Troitsky12-Jan-01 1:19 
I want to get a snapshot of the desktop, so I am trying to 'hide' the calling window, get the snapshot and then show the window and blit the snapshot to it's DC.

It works, but it seems to be capturing the calling DC (the one I'm hiding)....?

Here's the code:


///////////////////////////////////////////////////////////////////////////////////////////////////////////Function Header
void CDCUtils::PaintDesktop( CDC *pDC, CWnd* pWnd, CRect rect, bool bHideWindow )
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
CDC dcDesktop;
CDC dcBuffer;
CBitmap bmpBuffer;
CBitmap bmpDesktop;
CRect LastRect;

CWnd* pFrameWnd = pWnd->GetParentFrame();
pFrameWnd->GetWindowRect( LastRect );

//CPoint Point( rect.left, rect.top );
//HWND hWnd = pWnd->GetSafeHwnd();
//ClientToScreen(hWnd, &Point);
CPoint Point( LastRect.left, LastRect.top );

// Get the Calling Window out the way, so that we can get a clean snapshot...

if ( bHideWindow)
{
pFrameWnd->SetWindowPos( NULL, -100,0,0,0, NULL );
Sleep(400);
}

//
// Get the Desktop's Device Context
//

dcDesktop.m_hDC = ::GetDC(NULL);

//
// Initialise the bitmap according to the Desktop DC
//

bmpDesktop.CreateCompatibleBitmap( &dcDesktop,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));

//
// Create a buffer DC that has a bmp associated with it
//

dcBuffer.CreateCompatibleDC(&dcDesktop);
dcBuffer.SelectObject(bmpDesktop);

//
// Blit from the Desktop's (point.x, point.y) to the buffer's rectangle: 0,0,width,height
//

dcBuffer.BitBlt( 0,
0,
rect.Width(),
rect.Height(),
&dcDesktop, // From DC
Point.y,
Point.y,
SRCCOPY);

if ( bHideWindow)
{
pFrameWnd->SetWindowPos( NULL, LastRect.left, LastRect.top, LastRect.Width(), LastRect.Height(), NULL );
}

pDC->BitBlt( rect.left,
rect.top,
rect.Width(),
rect.Height(),
&dcBuffer, // From DC
0,
0,
SRCCOPY);

dcDesktop.DeleteDC();
dcBuffer.DeleteDC();

bmpDesktop.DeleteObject();
bmpBuffer.DeleteObject();
}


GeneralRe: Please tell me what's wrong in here... Pin
Christian Graus12-Jan-01 10:03
protectorChristian Graus12-Jan-01 10:03 
GeneralRe: Please tell me what's wrong in here... Pin
Jason Troitsky13-Jan-01 4:41
Jason Troitsky13-Jan-01 4:41 
GeneralRe: Please tell me what's wrong in here... Pin
Anders Molin13-Jan-01 7:22
professionalAnders Molin13-Jan-01 7:22 
QuestionHow to create a custom window class name in MFC Pin
James Spibey12-Jan-01 0:50
James Spibey12-Jan-01 0:50 
AnswerRe: How to create a custom window class name in MFC Pin
Michael Dunn12-Jan-01 13:57
sitebuilderMichael Dunn12-Jan-01 13:57 
GeneralCEditView and... Pin
11-Jan-01 23:45
suss11-Jan-01 23:45 
GeneralRe: CEditView and... Pin
Jason Troitsky12-Jan-01 2:07
Jason Troitsky12-Jan-01 2:07 
GeneralRe: CEditView and... Pin
12-Jan-01 6:28
suss12-Jan-01 6:28 
GeneralRe: CEditView and... Pin
12-Jan-01 6:32
suss12-Jan-01 6:32 
GeneralRe: CEditView and... Pin
12-Jan-01 2:11
suss12-Jan-01 2:11 
GeneralRe: CEditView and... Pin
12-Jan-01 6:35
suss12-Jan-01 6:35 
GeneralFonts in VC++ Code Editor Pin
11-Jan-01 17:51
suss11-Jan-01 17:51 
GeneralRe: Fonts in VC++ Code Editor Pin
Michael Dunn11-Jan-01 20:52
sitebuilderMichael Dunn11-Jan-01 20:52 
QuestionSound?? Pin
11-Jan-01 10:01
suss11-Jan-01 10:01 
QuestionSound?? Pin
11-Jan-01 10:01
suss11-Jan-01 10:01 
AnswerRe: Sound?? Pin
Christian Graus11-Jan-01 12:44
protectorChristian Graus11-Jan-01 12:44 
GeneralRe: Sound?? Pin
12-Jan-01 7:59
suss12-Jan-01 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.