From 203fbb45417f11e65a2836916776fe84bbbdffb8 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 2 Feb 2020 16:06:49 +0800 Subject: [PATCH] fixed #319 --- .../UserControl/Main/OverView.xaml | 2 +- .../Controls/Other/NotifyIcon.cs | 2 +- .../Tools/Interop/InteropMethods.cs | 5 +++++ .../Tools/Interop/InteropValues.cs | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml index 2b00d656..7284de08 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml @@ -7,7 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"> - + diff --git a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs index 831d7f22..cd15bd75 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs @@ -530,7 +530,7 @@ namespace HandyControl.Controls private void RegisterClass() { _windowClassName = $"HandyControl.Controls.NotifyIcon{Guid.NewGuid()}"; - var wndclass = new InteropValues.WNDCLASS + var wndclass = new InteropValues.WNDCLASS4ICON { style = 0, lpfnWndProc = _callback, diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs index 2af265bf..06bfb21d 100644 --- a/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs +++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs @@ -244,6 +244,11 @@ namespace HandyControl.Tools.Interop [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] internal static extern short RegisterClass(InteropValues.WNDCLASS wc); + [SecurityCritical] + [SuppressUnmanagedCodeSecurity] + [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] + internal static extern short RegisterClass(InteropValues.WNDCLASS4ICON wc); + [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)] internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs index 971fe31d..eed8f91d 100644 --- a/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs +++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs @@ -579,6 +579,21 @@ namespace HandyControl.Tools.Interop public string lpszClassName; } + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + internal class WNDCLASS4ICON + { + public int style; + public WndProc lpfnWndProc; + public int cbClsExtra; + public int cbWndExtra; + public IntPtr hInstance; + public IntPtr hIcon; + public IntPtr hCursor; + public IntPtr hbrBackground; + public string lpszMenuName; + public string lpszClassName; + } + [StructLayout(LayoutKind.Sequential, Pack = 2)] internal struct BITMAPINFO {