Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Getting the Image of a WIndow

Getting the Image of a WIndow

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vladimir_india
    wrote on last edited by
    #1

    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

    L R 2 Replies Last reply
    0
    • V 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

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      u can send it a wm_paint message and pass a dc in it should render to the dc u pass in :)


      "there is no spoon"
      biz stuff   about me

      V 1 Reply Last reply
      0
      • V 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

        R Offline
        R Offline
        Robert Kuster
        wrote on last edited by
        #3

        Check this: Window Contents Capturing using WM_PRINT Message[^] RK

        V 1 Reply Last reply
        0
        • L l a u r e n

          u can send it a wm_paint message and pass a dc in it should render to the dc u pass in :)


          "there is no spoon"
          biz stuff   about me

          V Offline
          V Offline
          vladimir_india
          wrote on last edited by
          #4

          Sorry dear, i'm afraid but wm_paint doesnt solves the problem! -vladiir_india

          1 Reply Last reply
          0
          • R Robert Kuster

            Check this: Window Contents Capturing using WM_PRINT Message[^] RK

            V Offline
            V Offline
            vladimir_india
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups