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. Cutout window (creating a "hole")

Cutout window (creating a "hole")

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
4 Posts 2 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.
  • K Offline
    K Offline
    kb
    wrote on last edited by
    #1

    Hi, I want to create a dialogue box that has a hole in it... Essentially, it is a window that covers another window created by another application. But I want a square hole in my dialogue that shows part of the window beneath it (kind of like those envelopes that you get with a square cutout in the front showing your address that is printed on the letter it contains). Does anybody know how I can do this? I am using the Windows API. Many thanks for any suggestions, Keith

    M 1 Reply Last reply
    0
    • K kb

      Hi, I want to create a dialogue box that has a hole in it... Essentially, it is a window that covers another window created by another application. But I want a square hole in my dialogue that shows part of the window beneath it (kind of like those envelopes that you get with a square cutout in the front showing your address that is printed on the letter it contains). Does anybody know how I can do this? I am using the Windows API. Many thanks for any suggestions, Keith

      M Offline
      M Offline
      mishgun
      wrote on last edited by
      #2

      HRGN hOrgRgn; ::GetWindowRgn(hWnd, hOrgRgn); HRGN hRectRgn = ::CreateRectRgn(0, 0, 100, 100); HRGN hResultRgn; ::CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR); ::SetWindowRgn(hWnd, hResultRgn); something like this should help :) nobody is perfect

      K 1 Reply Last reply
      0
      • M mishgun

        HRGN hOrgRgn; ::GetWindowRgn(hWnd, hOrgRgn); HRGN hRectRgn = ::CreateRectRgn(0, 0, 100, 100); HRGN hResultRgn; ::CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR); ::SetWindowRgn(hWnd, hResultRgn); something like this should help :) nobody is perfect

        K Offline
        K Offline
        kb
        wrote on last edited by
        #3

        Hi, many thanks for your reply. I tried the rgn method, and finally got this code working: hOrgRgn=CreateRectRgn(0,0,0,0); GetWindowRgn(hWnd, hOrgRgn); hRectRgn = CreateRectRgn(50, 10, 200, 200); hResultRgn=CreateRectRgn(0,0,0,0); CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR);//RGN_DIFF); //rgn_diff makes no difference SetWindowRgn(hWnd, hResultRgn,TRUE); But unfortunately, this does exactly the *opposite* of what I want. This cuts out a square from the middle of the window, but it only shows the cut out square and not the rest of the window; I want to show the window with a square hole in the middle. I've tried swapping around "hOrgRgn" and "hRectRgn" in CombineRgn(), but it makes no difference. Does anybody have any suggestions? Again, many thanks, Keith

        M 1 Reply Last reply
        0
        • K kb

          Hi, many thanks for your reply. I tried the rgn method, and finally got this code working: hOrgRgn=CreateRectRgn(0,0,0,0); GetWindowRgn(hWnd, hOrgRgn); hRectRgn = CreateRectRgn(50, 10, 200, 200); hResultRgn=CreateRectRgn(0,0,0,0); CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR);//RGN_DIFF); //rgn_diff makes no difference SetWindowRgn(hWnd, hResultRgn,TRUE); But unfortunately, this does exactly the *opposite* of what I want. This cuts out a square from the middle of the window, but it only shows the cut out square and not the rest of the window; I want to show the window with a square hole in the middle. I've tried swapping around "hOrgRgn" and "hRectRgn" in CombineRgn(), but it makes no difference. Does anybody have any suggestions? Again, many thanks, Keith

          M Offline
          M Offline
          mishgun
          wrote on last edited by
          #4

          // get screen coordinates RECT OrgRect; GetWindowRect(hWnd, &OrgRect); POINT ptLT, ptRB; ptLT.x = OrgRect.left; ptLT.y = OrgRect.top; ptRB.x = OrgRect.right; ptRB.y = OrgRect.bottom; // convert to client ScreenToClient(hWnd, &ptLT); ScreenToClient(hWnd, &ptRB); // convert from client area to entire window area ptRB.x -= ptLT.x; ptRB.y -= ptLT.y; ptLT.x -= ptLT.x; ptLT.y -= ptLT.y; // create new region for window HRGN hNewRgn = CreateRectRgn(ptLT.x, ptLT.y, ptRB.x, ptRB.y); // "hole" region HRGN hRectRgn = CreateRectRgn(ptLT.x+50, ptLT.y+50, ptRB.x-50, ptRB.y-50); // combine them HRGN hResultRgn = CreateRectRgn(0, 0, 0, 0); CombineRgn(hResultRgn, hNewRgn, hRectRgn, RGN_DIFF); SetWindowRgn(hWnd, hResultRgn, TRUE); this one works for sure can send you a demo project nobody is perfect

          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