I purposely named it IsHwndVisible() so as not to clash with IsWindowVisible_() when searching/replacing your sources.
Code: Select all
Prototype DwmGetWindowAttribute_(hWnd,dwAttribute.l,*pvAttribute,cbAttribute.l)
Procedure IsHwndVisible(hWnd)
vis=-1 ; Means hWnd not found or couldn't determine visibility status.
c$=Space(999)
GetClassName_(hWnd,c$,999)
If c$<>"ApplicationFrameWindow" And c$<>"Windows.UI.Core.CoreWindow" ; Normal Win32 window.
vis=IsWindowVisible_(hWnd)
If vis<>0 : vis=1 : EndIf
Else ; Windows 10 UWP window, which can return non-zero for IsWindowVisible_() despite not shown!
Define DwmGetWindowAttribute_.DwmGetWindowAttribute_
#DWMWA_CLOAKED=14
DWMAPIDLL=OpenLibrary(#PB_Any,"DWMAPI.DLL")
If DWMAPIDLL
DwmGetWindowAttribute_=GetFunction(DWMAPIDLL,"DwmGetWindowAttribute")
If DwmGetWindowAttribute_ And DwmGetWindowAttribute_(hWnd,#DWMWA_CLOAKED,@Cloaked,SizeOf(Cloaked))=#S_OK
If Cloaked=0
vis=1
Else
vis=0
EndIf
EndIf
CloseLibrary(DWMAPIDLL)
EndIf
EndIf
ProcedureReturn vis
EndProcedure
Debug IsHwndVisible(FindWindow_(0,"Untitled - Notepad")) ; Standard Win32 window.
Debug IsHwndVisible(FindWindow_(0,"Microsoft Store")) ; Windows 10 UWP window.