Skip to content

Commit 1a47c35

Browse files
committed
apply workaround for scaling issues
1 parent 3f916c9 commit 1a47c35

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Program.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Diagnostics;
45
using System.Linq;
6+
using System.Reflection;
57
using System.Text.RegularExpressions;
68
using System.Windows.Forms;
79
using Microsoft.Win32.TaskScheduler;
@@ -300,4 +302,23 @@ protected override void Dispose(bool isDisposing)
300302
base.Dispose(isDisposing);
301303
}
302304
}
305+
public class ContextMenuStrip : System.Windows.Forms.ContextMenuStrip
306+
{
307+
private new void RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNew)
308+
{
309+
// Use reflection to invoke the internal ResetScaling method
310+
var resetScalingMethod = typeof(System.Windows.Forms.ContextMenuStrip).GetMethod("ResetScaling", BindingFlags.NonPublic | BindingFlags.Instance);
311+
resetScalingMethod?.Invoke(this, [deviceDpiNew]);
312+
}
313+
314+
public ContextMenuStrip(IContainer container) : base(container)
315+
{
316+
RescaleConstantsForDpi(96, DeviceDpi);
317+
}
318+
319+
public ContextMenuStrip()
320+
{
321+
RescaleConstantsForDpi(96, DeviceDpi);
322+
}
323+
}
303324
}

0 commit comments

Comments
 (0)