Open KamilSzymborski opened 4 years ago
Is this a suggested fix?
I know why you ask - I forgot to mention something: the problem occurs when the interface scaling in the system is greater than 100% - then the application scales.
SetProcessDpiAware is the same as right click -> properties -> compatibility -> change high DPI settings -> high DPI scalling override: application on exe, or link.
I don't know how to fix it.
Oh sorry, NOT ALWAYS, in my case it occurs when scaling 150%.
I have 13" inch notebook with FHD.
mb.
Ok let try to replicate the issue based on the information that you provided. Thanks a lot for your findings.
Good luck!
within your project select Add new file and add a "application manifest", add the following in the manifest file:
add-inside-app-manifest-file.zip
Then open your project properties, select application tab then go to the manifest section, select your newly created manifest file, close property window and rebuild solution - should fix your problem.
Still the same at 150% on 13" on Full HD.
This is just one of the ways to enable dpi aware.
Hi, within the manifest file inside assembly identity node is that the name of your application? if not input the name of your app.exe.
Try - within form properties select "AutoScaleMode" change from "Font" to "DPI" see if this helps.
failing that, i'll code up a sample app for all different dpi and upload it here - give me a day or so.
Hi, within the manifest file inside assembly identity node is that the name of your application? if not input the name of your app.exe.
Corrected. However, everything worked fine, the application without scaling on my device looks terrible and you can't miss it.
Try - within form properties select "AutoScaleMode" change from "Font" to "DPI" see if this helps.
I tried.
failing that, i'll code up a sample app for all different dpi and upload it here - give me a day or so.
I know how to write applications that scale well.
I generally don't use MetroForm because I don't like - I only use components from MetroFramework.
I just wanted to report a bug.
But I appreciate the willingness.
:)
I fixed it.
Original:
newButton.Size = new Size(25, 20);
To (x and y +4):
newButton.Size = new Size(29, 24);
There was simply no space for text on the button.
It's a solution for my 13-inch Full HD laptop. But it will probably be bad again with 12-inch Full HD etc. Maybe you need to provide a picture instead of button text.
And it would be good to add scaling options to MetroForm.
if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
@KamilSzymborski I still do not understand how you were able to fix the maximize and minimize boxes in the Control Box using DPI Aware. Could you elaborate on how you fixed that?
Finally I solved this by implementing auto-scaling to the window buttons.
float dpi;
using (var g = newButton.CreateGraphics())
// 96 is base /default DPI, is like 100% system scaling
dpi = (96 / Math.Max(g.DpiX, g.DpiY));
var oldButtonSize = newButton.Size;
var newButtonWidth = Convert.ToInt32(oldButtonSize.Width + (oldButtonSize.Width * dpi));
var newButtonHeight = Convert.ToInt32(oldButtonSize.Height + (oldButtonSize.Height * dpi));
newButton.Size = new Size(newButtonWidth, newButtonHeight);
I am sending you MetroForm.cs - replace it in MetroFramework/Forms.
Kamil,
Thank you very much!!! I can't express my gratitude enough, this really helped with the issue I was dealing with.
On Sat, Feb 20, 2021 at 12:02 AM Kamil Szymborski notifications@github.com wrote:
Finally I solved this by implementing auto-scaling to the window buttons.
float dpi; using (var g = newButton.CreateGraphics()) dpi = (96 / Math.Max(g.DpiX, g.DpiY)); var oldButtonSize = newButton.Size; var newButtonWidth = Convert.ToInt32(oldButtonSize.Width + (oldButtonSize.Width dpi));var newButtonHeight = Convert.ToInt32(oldButtonSize.Height + (oldButtonSize.Height dpi)); newButton.Size = new Size(newButtonWidth, newButtonHeight);
I am sending you MetroForm.cs - replace it in MetroFramework/Forms.
MetroForm.zip https://github.com/dennismagno/metroframework-modern-ui/files/6014224/MetroForm.zip
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dennismagno/metroframework-modern-ui/issues/97#issuecomment-782567770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFC3CJGHV2JHUGPQLZ6KRCTS75F7XANCNFSM4H66BC7A .
https://ibb.co/gVbzkkr