Skip to content

Fix Issue 14167: [HDPI] Cursor editor some items are not displayed in propertyGrid with special DPI settings - #15049

Open
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_14167
Open

Fix Issue 14167: [HDPI] Cursor editor some items are not displayed in propertyGrid with special DPI settings#15049
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_14167

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Sep 7, 2026

Copy link
Copy Markdown
Member

Fixes #14167

Root Cause

The issue with the CurSor icon offset was introduced by #14575. CursorEditor.CursorUI uses a "uniform icon column width" when drawing Cursor dropdowns, but this width is only calculated based on Cursors.Default.

At high DPI or with certain cursors (such as NoMove2D / NoMoveHoriz / NoMoveVert / HSplit / VSplit), the actual drawn width may be greater than this column width, causing icons to go out of bounds, overlap with text areas, or appear truncated.

Proposed changes

The calculation logic for shared icon column width has been changed from "only Cursors.Default" to "the maximum width of all standard Cursors at the current DPI":

  • During initialization and DPI changes, the standard Cursor set is traversed and the maximum scaling width is calculated.
  • This maximum value is used as the unified _cursorWidth to draw each row, maintaining consistent column alignment.
  • The existing caching mechanism is retained to avoid the drawing overhead caused by repeated scaling calculations.
  • Regression tests are added to verify that _cursorWidth equals the maximum width in the standard Cursor set.

Customer Impact

  • Fixed the issue of out-of-bounds/overlapping Cursor drop-down list icons under high DPI.
  • All Cursor items maintain consistent icon column width and text alignment when first displayed.
  • Improved PropertyGrid design-time experience to reduce visual anomalies and misjudgments as resource loading failures.

Regression?

  • Yes

Risk

  • Mini

Screenshots

Before

image

After

125%

Recording.2026-09-07.145716.mp4

150%

Recording.2026-09-07.151123.mp4

175%

Recording.2026-09-07.150053.mp4

225%

Recording.2026-09-07.150421.mp4

350%

Recording.2026-09-07.151411.mp4

Test methodology

  • Manual
  • Automation Test

Accessibility testing

Test environment(s)

  • 11.0.0-preview.7.26381.103
Microsoft Reviewers: Open in CodeFlow

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new owner-draw path should acquire the HDC via DrawItemEventArgs (IHdcContext/IGraphicsHdcProvider) to preserve WM_DRAWITEM DC state/clipping and avoid unnecessary Graphics↔HDC state churn.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR addresses HDPI rendering issues in the PropertyGrid cursor dropdown by ensuring the icon column width is computed using the widest standard cursor at the current DPI, preventing truncation/overlap for wider cursors.

Changes:

  • Recompute the shared cursor icon column width as the maximum width across all standard cursors for the active DPI.
  • Adjust owner-draw rendering logic and add redraw hooks to improve first-paint correctness when the dropdown becomes visible.
  • Add unit tests validating _cursorWidth selection logic, cache rebuild behavior, and graphics clip restoration.
File summaries
File Description
src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs Recalculates uniform cursor column width from the standard cursor set and updates owner-draw rendering/redraw behavior.
src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs Adds regression tests for widest-cursor width selection, cache rebuild on Start/End, and clip restoration during drawing.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Simon Zhao (BEYONDSOFT CONSULTING INC) added 2 commits September 7, 2026 15:57
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.24166%. Comparing base (b0a7c95) to head (d85f8e5).

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15049   +/-   ##
=============================================
  Coverage   37.24166%   37.24166%           
=============================================
  Files            246         246           
  Lines           9774        9774           
  Branches        1029        1029           
=============================================
  Hits            3640        3640           
  Misses          5970        5970           
  Partials         164         164           
Flag Coverage Δ
Debug 37.24166% <ø> (ø)
production 39.36526% <ø> (ø)
test 20.64923% <ø> (ø)
unit 39.36526% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HDPI] Cursor editor some items are not displayed in propertyGrid with special DPI settings

2 participants