add SystemMenuHook
This commit is contained in:
1 parent
a9720f080b
commit
3d32e17afd
15 files changed
+236
-219
No files matched your search
@@ -109,7 +109,7 @@ namespace HandyControl.Controls
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
window = VisualHelper.GetActiveWindow();
|
||||
window = WindowHelper.GetActiveWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (string.IsNullOrEmpty(_token))
|
||||
{
|
||||
Close(VisualHelper.GetActiveWindow());
|
||||
Close(WindowHelper.GetActiveWindow());
|
||||
}
|
||||
else if (WindowDic.TryGetValue(_token, out var window))
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
@@ -508,26 +507,14 @@ namespace HandyControl.Controls
|
||||
Content = ContextContent
|
||||
};
|
||||
_contextContent.IsOpen = true;
|
||||
var handle = IntPtr.Zero;
|
||||
var hwndSource = (HwndSource)PresentationSource.FromVisual(_contextContent.Child);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
handle = hwndSource.Handle;
|
||||
}
|
||||
UnsafeNativeMethods.SetForegroundWindow(handle);
|
||||
UnsafeNativeMethods.SetForegroundWindow(_contextContent.Child.GetHandle());
|
||||
}
|
||||
else if (ContextMenu != null)
|
||||
{
|
||||
ContextMenu.Placement = PlacementMode.Mouse;
|
||||
ContextMenu.IsOpen = true;
|
||||
|
||||
var handle = IntPtr.Zero;
|
||||
var hwndSource = (HwndSource)PresentationSource.FromVisual(ContextMenu);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
handle = hwndSource.Handle;
|
||||
}
|
||||
UnsafeNativeMethods.SetForegroundWindow(handle);
|
||||
UnsafeNativeMethods.SetForegroundWindow(ContextMenu.GetHandle());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace HandyControl.Controls
|
||||
Data = accentPtr
|
||||
};
|
||||
|
||||
ExternDllHelper.SetWindowCompositionAttribute(new WindowInteropHelper(window).Handle, ref data);
|
||||
ExternDllHelper.SetWindowCompositionAttribute(window.GetHandle(), ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace HandyControl.Controls
|
||||
throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult));
|
||||
}
|
||||
|
||||
var ownerWindow = owner ?? VisualHelper.GetActiveWindow();
|
||||
var ownerWindow = owner ?? WindowHelper.GetActiveWindow();
|
||||
var ownerIsNull = ownerWindow is null;
|
||||
|
||||
return new MessageBox
|
||||
|
||||
Reference in new issue
Block a user