Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 0d245a7

Browse files
committed
Show Windows Context Menu on the screen that has the mouse cursor.
1 parent 7a2960e commit 0d245a7

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Main.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,10 @@ public List<Result> LoadContextMenus(Result selectedResult)
333333
{
334334
var fileInfos = new FileInfo[] { new(record.FullPath) };
335335

336-
var showPosition = new System.Drawing.Point
337-
(
338-
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2,
339-
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2
340-
);
336+
var screenWithMouseCursor = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position);
337+
var xOfScreenCenter = screenWithMouseCursor.WorkingArea.Left + screenWithMouseCursor.WorkingArea.Width / 2;
338+
var yOfScreenCenter = screenWithMouseCursor.WorkingArea.Top + screenWithMouseCursor.WorkingArea.Height / 2;
339+
var showPosition = new System.Drawing.Point(xOfScreenCenter, yOfScreenCenter);
341340

342341
new Peter.ShellContextMenu().ShowContextMenu(fileInfos, showPosition);
343342

0 commit comments

Comments
 (0)