0

I have a form that doesn't seem to respect Autoscale when the user has set something other than 100% in their display settings.

Anyone have any idea what's happening here?

Here are the specific conditions that I've narrowed it down to:

  • WinForms project
  • Put an image on a button (not shown in images below due to scaling of image on button)
  • Add a WPF User Control to the project (no need to reference it from the WinForm)

Notes

  • Removal of either the WPF User Control or the image on the button (the resource can stay) results in the expected scaling
  • In the bad scaling example note that there is no window icon or window text...Maybe a clue?
  • It's hard to tell, but it looks like it flashes on screen at the correct scaling then is redrawn at the wrong scaling.

Images

Bad Result (no scaling):

Unscaled

Expected Result (expected scaling):

enter image description here

Project:

enter image description here

MikeH
  • 4,242
  • 1
  • 17
  • 32
  • The project window image provides no useful information, please remove it. – jwdonahue Mar 05 '18 at 23:54
  • @jwdonahue I disagree, I think that it adds a simple reference for someone trying to recreate the problem. However, if others feel the same as you I'll remove it. – MikeH Mar 05 '18 at 23:56
  • It's not exactly an [MCVE]. – jwdonahue Mar 05 '18 at 23:59
  • 2
    Using any WPF control will cause your program to declare itself dpiAware. Clearly it is not. You can take the blue pill and [declare your app to be dpiAware](https://stackoverflow.com/a/13228495/17034) so you have a consistent bug in your code to fix. Or you can take the red pill and [stop WPF from doing this](https://msdn.microsoft.com/en-us/library/system.windows.media.disabledpiawarenessattribute(v=vs.110).aspx). Nobody can guess what pill you favor. – Hans Passant Mar 06 '18 at 00:04
  • @HansPassant Thank you so much! A quick test shows that the red pill gives me the expected results. I'll have to do some more testing to ensure there aren't any unexpected consequences. Add an answer and I'll mark it as accepted. – MikeH Mar 06 '18 at 00:14
  • 3
    You asked for help on a site that only promotes blue pills. Clearly I cannot post an answer like that. – Hans Passant Mar 06 '18 at 00:32

0 Answers0