0

I am using this code its simple code but for some reason it always returning the partially covered despite the windows is fully covered or uncovered.

I am using this in the EnumWindows

  HDC hdc = GetDC(hWnd);
    if (hdc) {
        RECT rcClip, rcClient;
    
        switch (GetClipBox(hdc, &rcClip)) {
        case NULLREGION:
            LOGGER->info("completely covered"); break;
        case SIMPLEREGION:
            GetClientRect(hWnd, &rcClient);
            if (EqualRect(&rcClient, &rcClip)) {
                LOGGER->info("completely uncovered");
            }
            else {
                LOGGER->info("partially covered");
            }
            break;
        case COMPLEXREGION:
            LOGGER->info("partially covered");
            break;
        default:
            LOGGER->info("no result");
        }
    }
Zeus
  • 3,703
  • 3
  • 7
  • 20
dinesh lpu
  • 11
  • 5
  • I personally always avoid logging the same output in different cases. – molbdnilo Jan 20 '21 at 12:30
  • The code seems to work fine for me, how do you implement the `LOGGER->info` function. I can record the coverage of all windows by writing a file. – Zeus Jan 21 '21 at 05:19
  • @ZhuSong-MSFT For Logging part , I am using spdlog. – dinesh lpu Jan 21 '21 at 06:54
  • @ZhuSong-MSFT if you dont mind can you provide the souce file please. – dinesh lpu Jan 21 '21 at 06:54
  • @dineshlpu I use the same code, just replace `LOGGER->info` with writing to a file. I tried to test `notepad`, when it is completely on the desktop, it outputs `completely uncovered`, and when it is partially outside the desktop Output `partially covered`, output `completely uncovered` when it is minimized or not at all on the desktop – Zeus Jan 21 '21 at 07:08
  • @ZhuSong-MSFT okay thankyou. Does it work if the notepad is covered by the other windows?? – dinesh lpu Jan 21 '21 at 07:30
  • @dineshlpu Covering by other windows will not affect the result, because you use `GetClipBox` and `EqualRect` to compare the logical coordinates of the window, and will not be affected by being covered by other windows. – Zeus Jan 21 '21 at 07:34
  • Is there any way that we could know if the window is visible to the user? – dinesh lpu Jan 21 '21 at 07:38
  • a duplicate? [How to determine if any part of the window is visible to Screen?](https://stackoverflow.com/questions/65786181/how-to-determine-if-any-part-of-the-window-is-visible-to-screen) – Zeus Jan 21 '21 at 07:41
  • consider a situation where many applications in restored size and I want to if one of the application windows is being shown.. – dinesh lpu Jan 21 '21 at 09:01
  • This should be a new question, maybe you can post a new question. – Zeus Jan 21 '21 at 09:50

0 Answers0