title: Function to check if a window is visible on screen does not work on Windows 7
body: <p>For my program, I need to know if at least a pixel of a window is visible on screen.</p>
  
  <p>I'm currently using this code:</p>
  
  <pre><code>BOOL isWindowVisible(HWND hwnd) {
      RECT r1;
      GetWindowRect(hwnd, &amp;r1);
      HRGN x = CreateRectRgnIndirect(&amp;r1);
  
      HWND s = GetTopWindow(0);
  
      do {
          if (IsWindowVisible(s)) {
              RECT r2;
              GetWindowRect(s, &amp;r2);
              HRGN y = CreateRectRgnIndirect(&amp;r2);
  
              int res = CombineRgn(x, x, y, RGN_DIFF);
              DeleteObject(y);
              if (res == NULLREGION) {
                  DeleteObject(x);
                  return FALSE;
              }
          }
      } while ((s = GetNextWindow(s, GW_HWNDNEXT)) &amp;&amp; s != hwnd);
  
      DeleteObject(x);
      return TRUE;
  }
  </code></pre>
  
  <p>This does work on Windows 8.1 and Windows 10, but not on Windows 7. On Windows 7, it returns <code>FALSE</code> every time.</p>
  
  <p>I thought it is because of Aero effects, but even when I disable it, it still happens. I got this method <a href="https://stackoverflow.com/a/3154853/1798024">here</a> on StackOverflow and adapted it to C++.</p>
  
  <p>Does someone know why this is happening?</p>