Repository navigation
Fix per-monitor DPI scaling and related layout regressions - #66
Open
mojingjing-git wants to merge 1 commit into
Open
mojingjing-git wants to merge 1 commit into
mojingjing-git wants to merge 1 commit into
Conversation
Let the existing PerMonitorV2 app configuration take effect and use DPI autoscaling consistently. Keep right-aligned Settings text within its allocated rows, preserve the hidden About layout, and size InputBox text to fit its content. Synchronize a newly opened form when native and WinForms DPI values differ, including explicit fonts, and retain the countdown clock's resize anchors. AI-Assistance: OpenAI Codex (implementation and local validation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My earlier claim that “the old version would inevitably get stretched and misaligned at 175%” was too strong. The original version just runs at the system DPI at startup, and it gets blurry when moved across monitors with different scaling. So my earlier change doesn’t prove the old version was wrong—it only shows the cross-monitor blurriness. That means those few lines I temporarily added really weren’t necessary.
Later, I use GPT-6 to dig into this.
The final fix is roughly this:
Dpi, with design sizes based on 96 DPI. That way, when a form moves across monitors, WinForms adjusts the controls to the target monitor’s DPI.AutoSizeand right anchoring; in testing, they ran outside the container or covered other text. I gave them fixed widths, kept right anchoring and right alignment, and adjusted the spacing between title sections. In the About group, I removed bottom anchoring, since it doesn’t work well for fixed-size forms. For InputBox, I measure how much height the current hint text needs and enlarge the window if needed; the countdown digit area gets repositioned after the first DPI sync, while keeping its anchors for window resizing. The actual layout changes are inSettings.Designer.cs,InputBox.cs, and a few other files.DeviceDpi. The newly addedDpiScaling.cschecks both values first; if they match, it does nothing. If they don’t, it sendsWM_DPICHANGEDto update WinForms’ scaling state, then adjusts the fonts explicitly set in the designer according to the DPI ratio.