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