Getting the Image of a WIndow
-
Hi All! Trying to get the image of a window using Hbitmap,DC,Memory DC and BitBlt. This works fine, but since the function BitBlt copies from the screen, I am having tough time gettin the image of a hidden or partially shadowed window. So is it possible to get the image of a window(even if its partially hidden) if we know its DC? I would also like to get more information on how does windows actually renders a DC. Can we force the rendering to a memory DC or memory buffer (instead to the screen) from where the image can be copied? Thanks! -Vladimir India
-
Hi All! Trying to get the image of a window using Hbitmap,DC,Memory DC and BitBlt. This works fine, but since the function BitBlt copies from the screen, I am having tough time gettin the image of a hidden or partially shadowed window. So is it possible to get the image of a window(even if its partially hidden) if we know its DC? I would also like to get more information on how does windows actually renders a DC. Can we force the rendering to a memory DC or memory buffer (instead to the screen) from where the image can be copied? Thanks! -Vladimir India
-
Hi All! Trying to get the image of a window using Hbitmap,DC,Memory DC and BitBlt. This works fine, but since the function BitBlt copies from the screen, I am having tough time gettin the image of a hidden or partially shadowed window. So is it possible to get the image of a window(even if its partially hidden) if we know its DC? I would also like to get more information on how does windows actually renders a DC. Can we force the rendering to a memory DC or memory buffer (instead to the screen) from where the image can be copied? Thanks! -Vladimir India
Check this: Window Contents Capturing using WM_PRINT Message[^] RK
-
Sorry dear, i'm afraid but wm_paint doesnt solves the problem! -vladiir_india
-
Check this: Window Contents Capturing using WM_PRINT Message[^] RK
Hats off! undoubtedly, its a great article. But something strange happened when i used WM_PRINT. None of the windows got printed, except my very own application window. Actually my application is kind of SPY++, so it identifies a window by mouse cursor position. The HWND is then send to the folowing function get_image(). following is the code snippet i'm using currently: BOOL CVenomDlg::get_image(HWND hwnd) { HBITMAP hBitmap ; HDC hdc,hdcMem; BITMAP bitmap ; RECT rc; ::GetWindowRect(hwnd,&rc);//get the bounding rectamgle hdc=::GetDC(hwnd);//get the dc hdcMem = ::CreateCompatibleDC (hdc) ;//create memory dc hBitmap = ::CreateCompatibleBitmap (hdc, rc.right-rc.left, rc.bottom-rc.top) ;//create bitmap ::GetObject (hBitmap, sizeof (BITMAP), &bitmap) ;//get bitmap info into bitmap struct ::SelectObject (hdcMem, hBitmap) ;//make the bitmap as the surface of memory dc ::SendMessage(hwnd, WM_PRINT , (WPARAM) hdcMem,PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED); ::ReleaseDC(hwnd,hdc); //copy the data to clipboard also! ::OpenClipboard(hwnd); ::EmptyClipboard(); ::SetClipboardData(CF_BITMAP, hBitmap); ::CloseClipboard(); //the clipboard contains a black rectangle??? //copy the image to static control... //my own stuff to copy the hdcMem contents to a //static control . . . . ::DeleteObject(hdcMem); ::DeleteObject(hBitmap); return(TRUE); } -Vladimir India