NotifyIcon Context Menu Position Fix

This commit is contained in:
Montilla Kryštof committed 2019-04-08 14:38:45 +02:00
1 parent 0f9cbd11dd
commit 40f5491f5c
4 files changed
+10 -12

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
@@ -36,7 +36,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -56,7 +56,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon> <ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
@@ -33,7 +33,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<netVersion>netgt40</netVersion> <netVersion>netgt40</netVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug-Net45|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug-Net45|AnyCPU' ">
@@ -66,7 +66,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\HandyControl.xml</DocumentationFile> <DocumentationFile>bin\Release\HandyControl.xml</DocumentationFile>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<netVersion>netgt40</netVersion> <netVersion>netgt40</netVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Net45|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Net45|AnyCPU' ">
@@ -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;