From 2a31fee528cd8ab88617861ce20bb310d4d1ed9d Mon Sep 17 00:00:00 2001 From: manstheram <96418420+manstheram@users.noreply.github.com> Date: Fri, 4 Aug 2023 07:42:37 +0100 Subject: [PATCH] Avoid "XamlExplorerHostIslandWindow" issues & Support for Insider Build (#1210) * Updated the toolkit Microsoft deprecated the old toolkit and released the same thing under a new name. * Update ModernFlyouts.Package.wapproj * Update README.md * Extra check for volume OSD - Checks the band the window is on to make sure that it is the volume bar * Fixes Windows 25000 Builds Allows flyout window to be painted without using a plane (or whatever it's called) so it can run on Windows Canary Builds. * Revert README.md * Revert name --- ModernFlyouts.Core/Interop/BandWindow.cs | 3 ++- ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs | 13 +++++++++---- ModernFlyouts.Core/Interop/NativeMethods.cs | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ModernFlyouts.Core/Interop/BandWindow.cs b/ModernFlyouts.Core/Interop/BandWindow.cs index cb32a70b..9325a1c6 100644 --- a/ModernFlyouts.Core/Interop/BandWindow.cs +++ b/ModernFlyouts.Core/Interop/BandWindow.cs @@ -351,7 +351,8 @@ public void CreateWindow() { WindowStyle = (int)(WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD), ParentWindow = hWnd, - UsesPerPixelTransparency = true + UsesPerPixelTransparency = true, + ExtendedWindowStyle = (int)(ExtendedWindowStyles.WS_EX_NOREDIRECTIONBITMAP) }; hwndSource = new(param) diff --git a/ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs b/ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs index cc94a90c..4584e473 100644 --- a/ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs +++ b/ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs @@ -371,10 +371,15 @@ private bool GetAllInfos() GetWindowThreadProcessId(hWndHost, out int pid); if (Process.GetProcessById(pid).ProcessName.ToLower() == "explorer") { - HWndHost = hWndHost; - HWndDUI = hWndDUI; - ShellProcessId = (uint)pid; - return true; + UIntPtr pdwBand = UIntPtr.Zero; + GetWindowBand(hWndHost, out pdwBand); + if (pdwBand == (UIntPtr)ZBandID.AboveLockUX) + { + HWndHost = hWndHost; + HWndDUI = hWndDUI; + ShellProcessId = (uint)pid; + return true; + } } } } diff --git a/ModernFlyouts.Core/Interop/NativeMethods.cs b/ModernFlyouts.Core/Interop/NativeMethods.cs index 29ed0c45..d4e8044a 100644 --- a/ModernFlyouts.Core/Interop/NativeMethods.cs +++ b/ModernFlyouts.Core/Interop/NativeMethods.cs @@ -778,6 +778,9 @@ internal static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLon [DllImport("user32.dll", SetLastError = true)] internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int processId); + [DllImport("user32.dll", SetLastError = true)] + internal static extern bool GetWindowBand(IntPtr hWnd, out UIntPtr pdwBand); + [DllImport("user32.dll", SetLastError = true)] internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);