Merge pull request #65 from HandyOrg/pr/64

Pr/64
This commit is contained in:
NaBian authored and GitHub committed 2019-04-08 22:03:46 +08:00
commit 37a0634b91
4 files changed
+6 -31

No files matched your search

+4
View File
@@ -18,3 +18,7 @@ src/Net_GE45/HandyControl_Net_GE45/obj
src/Net_GE45/HandyControlDemo_Net_GE45/bin src/Net_GE45/HandyControlDemo_Net_GE45/bin
src/Net_GE45/HandyControlDemo_Net_GE45/obj src/Net_GE45/HandyControlDemo_Net_GE45/obj
*.user *.user
/.vs/HandyControl/v16/.suo
/.vs/ProjectSettings.json
/.vs/VSWorkspaceState.json
/.vs/slnx.sqlite
@@ -322,8 +322,6 @@ namespace HandyControl.Controls
private void ShowContextMenu() private void ShowContextMenu()
{ {
var point = new POINT();
UnsafeNativeMethods.GetCursorPos(point);
if (ContextContent != null) if (ContextContent != null)
{ {
@@ -331,14 +329,12 @@ namespace HandyControl.Controls
{ {
_contextContent = new Popup _contextContent = new Popup
{ {
Placement = PlacementMode.AbsolutePoint, Placement = PlacementMode.Mouse,
AllowsTransparency = true, AllowsTransparency = true,
StaysOpen = false StaysOpen = false
}; };
} }
_contextContent.HorizontalOffset = point.x;
_contextContent.VerticalOffset = point.y;
_contextContent.Child = new ContentControl _contextContent.Child = new ContentControl
{ {
Content = ContextContent Content = ContextContent
@@ -354,9 +350,7 @@ namespace HandyControl.Controls
} }
else if (ContextMenu != null) else if (ContextMenu != null)
{ {
ContextMenu.Placement = PlacementMode.AbsolutePoint; ContextMenu.Placement = PlacementMode.Mouse;
ContextMenu.HorizontalOffset = point.x;
ContextMenu.VerticalOffset = point.y;
ContextMenu.IsOpen = true; ContextMenu.IsOpen = true;
var handle = IntPtr.Zero; var handle = IntPtr.Zero;
@@ -1,7 +1,5 @@
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace HandyControl.Tools.Interop namespace HandyControl.Tools.Interop
{ {
internal enum SM internal enum SM
@@ -99,21 +97,4 @@ namespace HandyControl.Tools.Interop
internal const int TRUE = 1; internal const int TRUE = 1;
internal const int FALSE = 0; internal const int FALSE = 0;
} }
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
public int x;
public int y;
public POINT()
{
}
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
}
} }
@@ -2,7 +2,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security; using System.Security;
using System.Text; using System.Text;
@@ -173,9 +172,6 @@ namespace HandyControl.Tools.Interop
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)] [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool GetCursorPos([In, Out] POINT pt);
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)] [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool SetForegroundWindow(IntPtr hWnd); public static extern bool SetForegroundWindow(IntPtr hWnd);
} }