Skip to content

Conversation

dreddy-work
Copy link
Member

@dreddy-work dreddy-work commented Jan 11, 2023

This change involves adding high DPI message handling to the NativeWindow class in order to support high DPI for components that are not derived from Control. As a result, the ErrorProvider, Timer, NotifyIcon, and ToolTip components will benefit from this change.
Changes:

  • Handling WM.DPICHANGED_BEFOREPARENT and WM.DPICHANGED_AFTERPARENT messages in NativeWindow
  • Replacing Windows Error Icon with WinForms specific Error Icon to remove dependency on Windows in ErrorProvider.
  • Scaling Error icon according to the Dpi of the monitor in PermonV2mode applications.

Fixes #8264

Microsoft Reviewers: Open in CodeFlow

- Adding following windows message handling in the NativeWinodow to support components that are not derived from Control.
	- WM.DPICHANGED_BEFOREPARENT
        - WM.DPICHANGED_AFTERPARENT
- Replacing Windows Error Icon with Winforms specific and remove dependancy on Windows.
@dreddy-work dreddy-work requested a review from a team as a code owner January 11, 2023 02:02
@ghost ghost assigned dreddy-work Jan 11, 2023
@dreddy-work dreddy-work changed the title Scaling ErrorProvider in for high dpi Scaling ErrorProvider for high dpi Jan 11, 2023
@elachlan
Copy link
Contributor

Test failure because you need to Update EmbeddedResourceTests because of the removal of IconInError.ico.

@dreddy-work
Copy link
Member Author

Test failure because you need to Update EmbeddedResourceTests because of the removal of IconInError.ico.

Thank you. It was not supposed to be removed. I was experimenting and forgot to add it back.

@Tanya-Solyanik
Copy link
Contributor

It was not supposed to be removed. I was experimenting and forgot to add it back.

Good to see unit test at work!

@dreddy-work dreddy-work enabled auto-merge (squash) January 11, 2023 21:24
{
case User32.WM.DPICHANGED_BEFOREPARENT:
WmDpiChangedBeforeParent(ref m);
m.ResultInternal = (LRESULT)0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Result is ignored by the system, I would delete all instances of us setting it.

Copy link
Member Author

@dreddy-work dreddy-work Jan 13, 2023

Choose a reason for hiding this comment

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

The m.ResultInternal is automatically set to (LRESULT)0 when the message is created, so there is no need for explicit setting. However, we have used this pattern in other places where we override or define WndProc.

Will have to revisit WndProc overrides in this code base to clean it up. Would consider a separate PR for that.

@dreddy-work dreddy-work added the 📚 documentation Open issue here - https://github.com/dotnet/dotnet-api-docs/issues label Jan 13, 2023
Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

Looks good

@dreddy-work dreddy-work merged commit 90242d4 into main Jan 13, 2023
@dreddy-work dreddy-work deleted the dev/dreddy/fix8264 branch January 13, 2023 23:47
@ghost ghost added this to the 8.0 Preview1 milestone Jan 13, 2023
dreddy-work added a commit that referenced this pull request Feb 10, 2023
We regressed this issue here: #8486

by accidentally disposing Icons that may not be owned or created by us. In this scenario, It was default Icon that is getting disposed.
@ghost ghost locked as resolved and limited conversation to collaborators Feb 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📚 documentation Open issue here - https://github.com/dotnet/dotnet-api-docs/issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Multi-Monitor][PerMonitorV2] ErrorProvider control is not scaled well on secondary screen
3 participants