Skip to content

Fix cursor editor icon width calculation for proper DPI scaling#14575

Open
SimonZhao888 wants to merge 1 commit into
dotnet:mainfrom
SimonZhao888:Fix_issue_14167
Open

Fix cursor editor icon width calculation for proper DPI scaling#14575
SimonZhao888 wants to merge 1 commit into
dotnet:mainfrom
SimonZhao888:Fix_issue_14167

Conversation

@SimonZhao888
Copy link
Copy Markdown
Member

@SimonZhao888 SimonZhao888 commented May 29, 2026

Fixes #14167

Root Cause

Icons similar to HSplit.cur, VSplit.cur are wider than other icons at certain DPI settings (such as 125%, 175%, 225%, 250%), which is causing the webtable to display abnormally.

Proposed changes

  • Modify the drawing method for list items to use the default icon width as a reference, ensuring that all icons are the same size.

Customer Impact

  • Cursor editor items are displayed correctly in propertyGrid with all DPI settings.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

image

After

150DPI:

150DPI.mp4

175DPI:

175DPI.mp4

200DPI:

200DPI.mp4

225DPI:

225DPI.mp4

Test methodology

  • Manually

Test environment(s)

  • 11.0.0-alpha.1.25619.109
Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow

@SimonZhao888
Copy link
Copy Markdown
Member Author

Here is another issue: when the DPI is set to 125%, 175%, 225%, 250%, the .cur icon exhibits an icon offset problem.
Normal:
image

Offset:
image

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates CursorEditor.CursorUI drawing to use a uniform cursor icon width, aiming to fix cursor editor item layout at fractional DPI settings in the PropertyGrid.

Changes:

  • Adds a cached _cursorWidth based on the scaled default cursor icon.
  • Updates owner-drawn cursor list items to use that uniform width for the icon box, cursor drawing, and text offset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +46
using Icon defaultIcon = Icon.FromHandle(Cursors.Default.Handle);
using Icon scaledDefaultIcon = ScaleHelper.ScaleSmallIconToDpi(defaultIcon, DeviceDpi);
_cursorWidth = scaledDefaultIcon.Size.Width;
@@ -70,11 +75,11 @@ protected override void OnDrawItem(DrawItemEventArgs e)
int cursorWidth = GetCursorWidthForDpi(cursor, DeviceDpi);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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