File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . ComponentModel ;
34using System . Diagnostics ;
45using System . Linq ;
6+ using System . Reflection ;
57using System . Text . RegularExpressions ;
68using System . Windows . Forms ;
79using 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}
You can’t perform that action at this time.
0 commit comments