0

My WinForms (C# .NET 4.6) application needs AutoScaleMode = Dpi for the sake of other features. This works great for 99% of my customers. They are typically using Windows Display Scaling of 100%, 125% or even %150.

However, I have a customer installation with a 3840x2160 screen at 250% scaling. On that system, my toolbar buttons become very strange like this:

enter image description here

The toolbar buttons seem to grow in height with the system scaling, but they do not grow in width. This makes a distorted view with tiny button images. How can I force toolbar buttons to scale in both directions and also have the button images scale accordingly?

Mark Malburg
  • 125
  • 1
  • 9
  • You have seen https://stackoverflow.com/questions/13228185/how-to-configure-an-app-to-run-correctly-on-a-machine-with-a-high-dpi-setting-e?rq=1 or any other posts on the subject? – rene Mar 17 '21 at 19:39
  • Thanks @rene I've looked there. It doesn't seem to address the toolbar. (Unless I'm missing something.) – Mark Malburg Mar 17 '21 at 19:46
  • So you have that manifest file with that content? And did all advice here: https://stackoverflow.com/a/4076259/578411 ? – rene Mar 17 '21 at 19:48
  • You're saying that you have set `AutoScaleMode = Dpi` but you didn't mention whether your app is actually DpiAware and, in that case, what DpiAwareness mode you have chosen. Note that the ToolStrip scales using the Font size. You can adapt your Button (since there's no text there), setting `AutoSize = false` and then setting a size that is the same as the ToolStrip height. More customization can be added to scale the image in different ways. -- The ToolStrip is one of those control that can opt-out the High-Dpi improvements using a dedicated setting in `app.config`, in case it's needed. – Jimi Mar 17 '21 at 20:08
  • See also [ScaleBitmapLogicalToDevice()](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.scalebitmaplogicaltodevice), [Scale()](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.scale) and friends. -- You need at least .Net Framework 4.7 to use the recent High-Dpi enhancements. I suggest to target .Net FW 4.8 (behaves better in many situations). Or move to .Net 5, if possible. – Jimi Mar 17 '21 at 20:13
  • 1
    https://stackoverflow.com/questions/3432025/how-to-increase-the-size-of-the-buttons-on-a-tool-strip – Hans Passant Mar 17 '21 at 21:46
  • 1
    https://stackoverflow.com/questions/33518339/resizing-toolstrip-items-image – Hans Passant Mar 17 '21 at 21:47

0 Answers0