This commit is contained in:
NaBian 2020-02-02 16:06:49 +08:00
parent e9a7123398
commit 203fbb4541
4 changed files with 22 additions and 2 deletions

View File

@ -7,7 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"> xmlns:userControl="clr-namespace:HandyControlDemo.UserControl">
<ScrollViewer HorizontalScrollBarVisibility="Auto"> <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center" Name="CanvasMain" Margin="32" Width="1665" Height="1300"> <Canvas HorizontalAlignment="Center" VerticalAlignment="Center" Name="CanvasMain" Margin="32" Width="1665" Height="1300">
<Border Visibility="Visible" BorderThickness="0" Padding="16" Style="{StaticResource BorderRegion}" CornerRadius="4"> <Border Visibility="Visible" BorderThickness="0" Padding="16" Style="{StaticResource BorderRegion}" CornerRadius="4">
<StackPanel> <StackPanel>

View File

@ -530,7 +530,7 @@ namespace HandyControl.Controls
private void RegisterClass() private void RegisterClass()
{ {
_windowClassName = $"HandyControl.Controls.NotifyIcon{Guid.NewGuid()}"; _windowClassName = $"HandyControl.Controls.NotifyIcon{Guid.NewGuid()}";
var wndclass = new InteropValues.WNDCLASS var wndclass = new InteropValues.WNDCLASS4ICON
{ {
style = 0, style = 0,
lpfnWndProc = _callback, lpfnWndProc = _callback,

View File

@ -244,6 +244,11 @@ namespace HandyControl.Tools.Interop
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
internal static extern short RegisterClass(InteropValues.WNDCLASS wc); 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)] [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

View File

@ -579,6 +579,21 @@ namespace HandyControl.Tools.Interop
public string lpszClassName; 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)] [StructLayout(LayoutKind.Sequential, Pack = 2)]
internal struct BITMAPINFO internal struct BITMAPINFO
{ {