Dual monitor dialog resize issue
See original GitHub issueNote: Considering my last bug report for the .NET Framework at the developer community has been migrated to the corresponding .NET Core project I report this issue directly here. Please note though that .NET Framework is also affected.
Issue reproduction steps:
- Make sure your secondary display is left or above of your primary display (so it has negative relative coordinates)
- Create a new Windows Forms Application and display a form by
ShowDialogso the resize grip is visible. - Execute the application and drag the form to the secondary display.
- Now as its coordinates are in the negative range, move the mouse along the border and see that the diagonal resize cursor appears all around the form. The issue is not just the displayed cursor but also the resizing behavior behavior: even clicking the top border the bottom-right corner will be resized
See also the screenshot below (the cursor is indicated by me).

Proposed fix:
The root cause lies in the Form.WmNCHitTest method. m.LParam contains two short values but the way of converting them to integers is wrong.
Original code:
// This is wrong for negative values. For example, -500 will be interpreted as 65036
int x = NativeMethods.Util.LOWORD(m.LParam);
int y = NativeMethods.Util.HIWORD(m.LParam);
Fixed code:
// LParam contains two shorts. Without the cast negative values turn positive ints
int x = (short)(m.LParam.ToInt32() & 0xFFFF);
int y = (short)((m.LParam.ToInt32() >> 16) & 0xFFFF);
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Window resizing problem using dual monitors
- Click Start and type "resolution". - Select "Change display settings". - You should be able to modify the resolution for both monitors....
Read more >Windows applications resized incorrectly when moving ...
When using the Windows-Shift Right/Left keys to move between screens, the application usually gets resized incorrectly where it ends up being ...
Read more >Multi-Monitor dragging windows between screens resizes ...
When I right-click on my desktop and choose display, I see that both screens are set to 1920x1080 and I have them in...
Read more >Adjust Window Resize to Fit Dual Monitor Problem
If a window is positioned on the secondary monitor and the the script step "Adjust Window [Resize to Fit]" is run, the window...
Read more >Dialog window positioning is not preserved in AutoCAD ...
Issue: Dialog windows, dialog boxes, and palettes do not retain their positions or arrangement when exiting and relaunching AutoCAD products ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@koszeggy the daily build page doesn’t mention it but if you click the link the actual download section has 5.0 daily builds
I added the StatusBar fix to the PR. I didn’t change the ActiveX-related code found by @0xd4d though. Its test is a bit more complex and I think that would require another version of the
MAKELPARAMmethod as well.