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. How to capture the desktop image behind my main window

How to capture the desktop image behind my main window

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 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.
  • T Offline
    T Offline
    Tcpip2005
    wrote on last edited by
    #1

    I want to capture the desktop image behind my main window.I used HDC hDesktopDC = GetDC(NULL); RECT rect; GetWindowRect(&rect); ...... BitBlt(hMemDC, 0,0, nWidth, nHeight, hDesktopDC, rect->left, rect->top, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap); but, the image I got was my window,not Its background. what's the matter? How could I get the image behind my main window? Thanks guys!

    H _ G 3 Replies Last reply
    0
    • T Tcpip2005

      I want to capture the desktop image behind my main window.I used HDC hDesktopDC = GetDC(NULL); RECT rect; GetWindowRect(&rect); ...... BitBlt(hMemDC, 0,0, nWidth, nHeight, hDesktopDC, rect->left, rect->top, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap); but, the image I got was my window,not Its background. what's the matter? How could I get the image behind my main window? Thanks guys!

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      Hide your window first by calling ShowWindow(hwnd, SW_HIDE).

      Best wishes, Hans


      [Hans Dietrich Software]

      T 1 Reply Last reply
      0
      • T Tcpip2005

        I want to capture the desktop image behind my main window.I used HDC hDesktopDC = GetDC(NULL); RECT rect; GetWindowRect(&rect); ...... BitBlt(hMemDC, 0,0, nWidth, nHeight, hDesktopDC, rect->left, rect->top, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap); but, the image I got was my window,not Its background. what's the matter? How could I get the image behind my main window? Thanks guys!

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        You can minimize your application window first and then get the hWnd to the desktop window using the GetDesktopWindow.[^]Then you can maximize your application back again.

        I am a HUMAN. I have that keyword in my name........ ;-)_AnsHUMAN_

        1 Reply Last reply
        0
        • H Hans Dietrich

          Hide your window first by calling ShowWindow(hwnd, SW_HIDE).

          Best wishes, Hans


          [Hans Dietrich Software]

          T Offline
          T Offline
          Tcpip2005
          wrote on last edited by
          #4

          thanks hans. that would be fine,but there is always a flash.not perfect.

          1 Reply Last reply
          0
          • T Tcpip2005

            I want to capture the desktop image behind my main window.I used HDC hDesktopDC = GetDC(NULL); RECT rect; GetWindowRect(&rect); ...... BitBlt(hMemDC, 0,0, nWidth, nHeight, hDesktopDC, rect->left, rect->top, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap); but, the image I got was my window,not Its background. what's the matter? How could I get the image behind my main window? Thanks guys!

            G Offline
            G Offline
            goorley
            wrote on last edited by
            #5

            You could manipulate the clipping region for the desktop window before having it paint itself.

            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