diff --git a/CollapseLauncher/App.xaml b/CollapseLauncher/App.xaml
index 4f7592e46..27e0acbd1 100644
--- a/CollapseLauncher/App.xaml
+++ b/CollapseLauncher/App.xaml
@@ -666,6 +666,11 @@
+
+
+ 1
+
+
diff --git a/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml b/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml
index ae0fc4f39..120a72b9c 100644
--- a/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml
+++ b/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml
@@ -27,11 +27,37 @@
-
+
diff --git a/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs b/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs
index 18049b5b1..2d4c543b8 100644
--- a/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs
+++ b/CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
using Microsoft.UI;
+using Microsoft.UI.Input;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
@@ -133,35 +134,34 @@ public void InitializeWindowSettings()
m_presenter.IsResizable = false;
m_presenter.IsMaximizable = false;
- if (IsAppThemeLight)
- {
- m_appWindow.TitleBar.ButtonForegroundColor = new Windows.UI.Color { A = 255, B = 0, G = 0, R = 0 };
- m_appWindow.TitleBar.ButtonInactiveForegroundColor = new Windows.UI.Color { A = 0, B = 160, G = 160, R = 160 };
- m_appWindow.TitleBar.ButtonHoverBackgroundColor = new Windows.UI.Color { A = 64, B = 0, G = 0, R = 0 };
- }
- else
+ m_appWindow.TitleBar.ButtonBackgroundColor = new Windows.UI.Color { A = 0, B = 0, G = 0, R = 0 };
+ m_appWindow.TitleBar.ButtonInactiveBackgroundColor = new Windows.UI.Color { A = 0, B = 0, G = 0, R = 0 };
+
+ // Hide system menu
+ var controlsHwnd = FindWindowEx(m_windowHandle, 0, "ReunionWindowingCaptionControls", "ReunionCaptionControlsWindow");
+ if (controlsHwnd != IntPtr.Zero)
{
- m_appWindow.TitleBar.ButtonForegroundColor = new Windows.UI.Color { A = 255, B = 255, G = 255, R = 255 };
- m_appWindow.TitleBar.ButtonHoverBackgroundColor = new Windows.UI.Color { A = 64, B = 0, G = 0, R = 0 };
+ DestroyWindow(controlsHwnd);
}
- m_appWindow.TitleBar.ButtonBackgroundColor = new Windows.UI.Color { A = 0, B = 0, G = 0, R = 0 };
- m_appWindow.TitleBar.ButtonInactiveBackgroundColor = new Windows.UI.Color { A = 0, B = 0, G = 0, R = 0 };
+ // Fix mouse event
+ var incps = InputNonClientPointerSource.GetForWindowId(m_windowID);
+ incps.SetRegionRects(NonClientRegionKind.Close, null);
+ incps.SetRegionRects(NonClientRegionKind.Minimize, null);
+ var safeArea = new RectInt32[] { new(m_appWindow.Size.Width - (int)((144 + 12) * m_appDPIScale), 0, (int)((144 + 12) * m_appDPIScale), (int)(48 * m_appDPIScale)) };
+ incps.SetRegionRects(NonClientRegionKind.Passthrough, safeArea);
}
else
{
+ // Shouldn't happen
+ // https://learn.microsoft.com/en-us/windows/apps/develop/title-bar#colors
+
m_presenter.IsResizable = false;
m_presenter.IsMaximizable = false;
ExtendsContentIntoTitleBar = false;
+ AppTitleBar.Visibility = Visibility.Collapsed;
}
- // Hide minimize and maximize button
- int gwl_style = -16;
- uint minimizeBtn = 0x00020000;
- uint maximizeBtn = 0x00010000;
- var currentStyle = GetWindowLong(m_windowHandle, gwl_style);
- SetWindowLong(m_windowHandle, gwl_style, currentStyle & ~minimizeBtn & ~maximizeBtn);
-
MainFrameChangerInvoker.WindowFrameEvent += MainFrameChangerInvoker_WindowFrameEvent;
LauncherUpdateInvoker.UpdateEvent += LauncherUpdateInvoker_UpdateEvent;
}
@@ -319,5 +319,10 @@ private void MinimizeButton_Click(object sender, RoutedEventArgs e)
}
else m_presenter.Minimize();
}
+
+ private void CloseButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
}
}
diff --git a/Hi3Helper.Core/Classes/Data/InvokeProp.cs b/Hi3Helper.Core/Classes/Data/InvokeProp.cs
index 971ecf571..40e5d9327 100644
--- a/Hi3Helper.Core/Classes/Data/InvokeProp.cs
+++ b/Hi3Helper.Core/Classes/Data/InvokeProp.cs
@@ -20,7 +20,7 @@ public enum SystemMetric : int
public enum SetWindowPosFlags : uint
{
SWP_NOMOVE = 2,
- SWP_SHOWWINDOW = 40,
+ SWP_SHOWWINDOW = 0x40,
}
public enum SpecialWindowHandles
@@ -203,6 +203,12 @@ public struct WindowRect
[DllImport("user32.dll")]
public extern static uint SetWindowLong(IntPtr hwnd, int index, uint value);
+ [DllImport("user32.dll")]
+ public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
+
+ [DllImport("user32.dll")]
+ public static extern bool DestroyWindow(IntPtr hwnd);
+
public static IntPtr GetProcessWindowHandle(string ProcName) => Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ProcName), ".")[0].MainWindowHandle;
public class InvokePresence