Click here to Skip to main content
15,917,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem dealing with a function definition Pin
Anonymous1-Nov-04 6:19
Anonymous1-Nov-04 6:19 
GeneralRe: Problem dealing with a function definition Pin
NietzscheDisciple29-Oct-04 5:59
NietzscheDisciple29-Oct-04 5:59 
Generalpointer to template fuction instance Pin
magicAL127-Oct-04 10:33
magicAL127-Oct-04 10:33 
GeneralRe: pointer to template fuction instance Pin
Ryan Binns27-Oct-04 18:29
Ryan Binns27-Oct-04 18:29 
GeneralExecute RTF file. Pin
DanYELL27-Oct-04 10:31
DanYELL27-Oct-04 10:31 
GeneralRe: Execute RTF file. Pin
RobJones27-Oct-04 10:40
RobJones27-Oct-04 10:40 
GeneralCSocket::OnReceive problem Pin
ali khalilvand27-Oct-04 8:41
ali khalilvand27-Oct-04 8:41 
GeneralCapture window bitmap from another running program Pin
MugWumpBW27-Oct-04 8:35
MugWumpBW27-Oct-04 8:35 
I have a Visual C++ 6.0 program which needs to capture the client area bitmap from the window of another running application. I have the window handle of the target window and am able to get the bitmap if the target window is completely visible, but if the window is partially overlayed, then the bitmap capture gets the overlaying windows as well. I have read here and other sites that sending a WM_PRINT message to the target window and providing a device context will do this, but so far I have been unable to get this to work. The code I am using is the following:

-----------------------------------------------------------------------------------------
CRect rect;
CDC memDC;

CWnd* pWindow = CWnd::FromHandle( m_hWindow );

if ( ( pWindow != NULL ) && ( IsWindow( pWindow->m_hWnd ) == TRUE ) )
{
CDC* pClientDC = new CClientDC( pWindow );
CBitmap* pBitmap = new CBitmap();

pWindow->GetClientRect( &rect );
pBitmap->CreateCompatibleBitmap( pClientDC, rect.Width(), rect.Height() );

memDC.CreateCompatibleDC( pClientDC );
CBitmap* pOldBitmap = memDC.SelectObject( pBitmap );

// Adding this line and removing the next line did not work
//SendMessage( m_hWindow, WM_PRINT, ( WPARAM )memDC.GetSafeHdc(), PRF_CLIENT );

// This code captures the overlayed windows
memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pClientDC, 0, 0, SRCCOPY );

memDC.SelectObject( pOldBitmap );

ReleaseDC( m_hWindow, pClientDC->GetSafeHdc() );
delete pClientDC;
}
-----------------------------------------------------------------------------------------

What do I need to modify in this code so that the target window bitmap is captured even if the window is partially overlayed.

GeneralRe: Capture window bitmap from another running program Pin
l a u r e n27-Oct-04 15:10
l a u r e n27-Oct-04 15:10 
GeneralRe: Hiding Afx Pin
Maximilien27-Oct-04 7:52
Maximilien27-Oct-04 7:52 
GeneralRe: Hiding Afx Pin
jmkhael27-Oct-04 8:08
jmkhael27-Oct-04 8:08 
GeneralUnicode compiling Pin
Timothy Grabrian27-Oct-04 7:41
professionalTimothy Grabrian27-Oct-04 7:41 
GeneralRe: Unicode compiling Pin
l a u r e n27-Oct-04 15:11
l a u r e n27-Oct-04 15:11 
GeneralRe: Unicode compiling Pin
Timothy Grabrian27-Oct-04 15:25
professionalTimothy Grabrian27-Oct-04 15:25 
GeneralRe: Unicode compiling Pin
Ryan Binns27-Oct-04 18:40
Ryan Binns27-Oct-04 18:40 
GeneralHiding Afx Pin
Leyu27-Oct-04 7:28
Leyu27-Oct-04 7:28 
GeneralDrawing a line, fast! Pin
Obliterator27-Oct-04 6:43
Obliterator27-Oct-04 6:43 
GeneralPorting VB GUI to VC++ Pin
flashback827-Oct-04 6:39
flashback827-Oct-04 6:39 
GeneralRe: Porting VB GUI to VC++ Pin
BlackDice27-Oct-04 7:15
BlackDice27-Oct-04 7:15 
GeneralRe: Porting VB GUI to VC++ Pin
BlackDice27-Oct-04 7:19
BlackDice27-Oct-04 7:19 
GeneralRe: Porting VB GUI to VC++ Pin
flashback827-Oct-04 9:36
flashback827-Oct-04 9:36 
GeneralRe: Porting VB GUI to VC++ Pin
ThatsAlok27-Oct-04 18:58
ThatsAlok27-Oct-04 18:58 
GeneralCheck for Updates Pin
Anonymous27-Oct-04 6:04
Anonymous27-Oct-04 6:04 
GeneralRe: Check for Updates Pin
Ravi Bhavnani27-Oct-04 6:20
professionalRavi Bhavnani27-Oct-04 6:20 
QuestionIs the window on top? Pin
RobJones27-Oct-04 5:57
RobJones27-Oct-04 5:57 

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.