hi.
i am trying to get the contents of a visible (in the sense of WM_VISIBLE) but hidden (meaning blocked by other windows) window.
i have tried the following code, but it only produces a completely black image:
if instead ofCode:void PrintWindow(CWnd* window) //handle to window in question { //memory DC CDC memDC; //DC of window in question CDC *pDC = (*window).GetDC(); //make the memory DC compatible to window DC memDC.CreateCompatibleDC(pDC); //create a bitmap compatible to window DC, here just using 100x100 CBitmap bitmap; bitmap.CreateCompatibleBitmap(pDC, 100, 100); //select the bitmap into memory DC CBitmap *pOldBitmap = (CBitmap *)memDC.SelectObject(&bitmap); //sendmessage to window to print itself into memory DC (*window).SendMessage(WM_PRINT, (WPARAM)memDC.GetSafeHdc(), PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT ); //create the desktop DC to display the result CDC desktop; desktop.CreateDC("DISPLAY",NULL,NULL,NULL); //bit to bit transfer of memory DC onto the desktop desktop.BitBlt(0,0,100,100,&memDC,0,0,SRCCOPY); //this now shows a black rectangle on the top left corner of my desktop //then comes some cleanup (release all the DC's etc... }
i useCode:(*window).SendMessage(WM_PRINT, (WPARAM)memDC.GetSafeHdc(), PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT );
and then display memDC (again by bitblt) to desktop, then the correct image is shown (top left box of window), butCode:memDC.BitBlt(0,0,100,100,pDC,0,0,SRCCOPY);
only if the window is visible.
which is why i used sendmessage with WM_PRINT.
please help if you can, as this is coming a major obstacle in my application.
i am using windows xp with service pack 2.
thanks to everyone reading this.
imran



LinkBack URL
About LinkBacks


