0

I'm developing a windows form GUI, and came up with this tricky problem: When windows resolution is set to 100%, everything is normal, Good Sample: enter image description here

whereas when windows resolution is set to 150%, the graphical displays as well as the texts failed to autosize correctly, blocks messed up with each other, Bad sample:

enter image description here

Any advice would be helpful! Thanks.

NajiMakhoul
  • 1,623
  • 2
  • 16
  • 30
Alan Xie
  • 1
  • 2
  • 2
    Maybe try to use ```Dock``` or ```Anchor``` - I don't know if it's what you're looking for but you can give it a try. –  Dec 08 '20 at 21:37
  • 1
    try to use TableLayoutPanel in combination with the dock property of controls – henoc salinas Dec 08 '20 at 23:03

1 Answers1

0

Thanks guys and shout out to Ken White I've found my solution here: Creating a DPI-Aware Application

In short I added following and it worked:

namespace myApplication
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            // ***this line is added***
            if (Environment.OSVersion.Version.Major >= 6)
                SetProcessDPIAware();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        // ***also dllimport of that function***
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();
    }
}
Alan Xie
  • 1
  • 2