private IntPtr GetLastVisibleActivePopUpOfWindow(IntPtr window) { IntPtr lastPopUp = Win32Funcs.GetLastActivePopup(window); if (Win32Funcs.IsWindowVisible(lastPopUp)) { return(lastPopUp); } else if (lastPopUp == window) { return(IntPtr.Zero); } else { return(GetLastVisibleActivePopUpOfWindow(lastPopUp)); } }