Determining Window Visibility in Vista

I want to determine if any window is visible to the user or hidden / closed. In Windows XP, I would use the GetClipBox () function and check the NULLREGION value or the empty RECT value. This worked fine, but on Windows Vista it does not work if another window closes the window. In this case, GetClipBox () returns a SIMPLEREGION with a non-empty RECT.

Does anyone know why this does not work on Vista or is there another way to check if a window is visible to the user?

+3
source share
5 answers

, GetClipBox() NULLREGION DWM, - , ! DWM - ( , ) , , .

, , , .

, ! ( - , Windows Media, - , , , !) , ( XP on ) , , .

/TL; DR:

/ DWM, , , , , ( ! WM_PAINT , , , !).

+2

Vista ? , , , XP. , Vista DWM , , , .

+2

- / , , , Z-, , .

+1

Vista ? , , , XP. Vista DWM, , .

, DWM. , :

  • ""
  • ""
  • " "
  • ""

GetClipBox() . . , , :

DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);

However, this disables the transparency effects while my application is running, which is undesirable. I would prefer a less intrusive solution.

Anyway, thanks for the tip!

+1
source

Since you know what GetClipRect result is available for both XP and Vista (with DWM enabled and enabled), you can create a function to determine this, which takes different paths based on the OS. In psuedo code:

function bool IsWindowVisible()
{
   bool isVisible = false;

   if (OSVersion == "XP")
   {
      // GetClipRect tests which run on XP and set isVisible
   }
   else if (OSVersion == "Vista")
   {
      if (DWMCompisitionEnabled == true)
      {
         // GetClipRect tests for Vista with DWM enabled and set isVisible
      }
      else
      {
         // GetClipRect tests for Vista with DWM disabled and set isVisible
      }
   }
   return isVisible;
}
0
source

Source: https://habr.com/ru/post/1699151/


All Articles