[FIXED] SetWindowRgn freezes window


As the title says, I am having a problem with the window of an application freezing (not painting anymore) after I call SetWindowRgn. My source code is as follows:

    void MakeHole() 
      // This will make a hole you can see through for the MainToon window.
      HRGN thisHgrn = CreateRectRgn(10, 200, 300, 200);
      SetWindowRgn(hwndClientList[intMainToon], thisHgrn, TRUE);

I’m not even quite sure SetWindowRgn is the code I need to use. All I want to accomplish is a hole (transparent block) in a game window so that I can see through it. None of the other code in the project is really relevant at this point. Everything works as intended except that after I call SetWindowRgn, the game window doesn’t draw anymore. It looks frozen but I can still close the window and the sound is still playing clearly. This is a visual C++ console application but I don’t see how that could be of any importance either.
Let me know if you need anymore information.

Thanks for any help.


Fixed the problem with the following code.

    void MakeHole()
       // This will make a hole you can see through for the MainToon window.

       HRGN rgnOriginalWnd;
       HRGN rgnTheHole;
       HRGN rgnNewWnd;

       RECT rectDlg;
       GetWindowRect(hwndClientList[intMainToon], &rectDlg);

       rgnOriginalWnd = CreateRectRgn(0, 0, rectDlg.right - rectDlg.left, rectDlg.bottom - rectDlg.top);
       rgnTheHole = CreateRectRgn(10, 200, 350, 450);
       rgnNewWnd = CreateRectRgn(0, 0, 0, 0);

       CombineRgn(rgnNewWnd, rgnOriginalWnd, rgnTheHole, RGN_DIFF);
       SetWindowRgn(hwndClientList[intMainToon], rgnNewWnd, TRUE);


Answered By – Levi Roberts

Answer Checked By – Pedro (FixeMe Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *