Page 1 of 1

FormSizeChange in HighDPI PC

Posted: Mon Apr 25, 2016 5:43 am
by fukasawa
Hi,

I think Chart change FormSize in HighDPI PC.
It doesn't come up in my desktop PC.
Why is it Happend ?
And, How do it Fix?

1. Form Loaded, Chart is not create yet.
(Back screen is Excel)
1-start.png
1-start.png (29.46 KiB) Viewed 17295 times
2. Button1Clicked, Chart is created and Add in Panel.
FormSize is shrunk and location Changed.
2-button1Clicked.png
2-button1Clicked.png (51.32 KiB) Viewed 17295 times
3. Button2Clicked, Chart is Cleared in Panel.
FormSize and Location become normal.
3-button2Clicked.png
3-button2Clicked.png (29.24 KiB) Viewed 17295 times
4. Button1Clicked again, Chart is created and Add in Panel.
But FormSize and Location still NORMAL.

Code: Select all

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var lChart = new Arction.WinForms.Charting.LightningChartUltimate();
            this.splitContainer1.Panel1.Controls.Add(lChart);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.splitContainer1.Panel1.Controls.Clear();
        }
    }
Specs
My Desktop PC
OS: Win7 64bit
Display Size:23inch
Resolution:1920*1080
DPI 96pixel/inch

HighDPI PC
OS: Win10 64bit
Display Size:13.3inch
Resolution:1920*1080
DPI 166pixel/inch

Re: FormSizeChange in HighDPI PC

Posted: Mon Apr 25, 2016 4:18 pm
by ArctionPasi
Hi Fukasawa,

Our support personnel will answer you soon.

Re: FormSizeChange in HighDPI PC

Posted: Tue Apr 26, 2016 2:04 pm
by ArctionLasse
Hi Fukasawa,

the behavior is indeed related to DPI system. In windows applications can be in one of 3 different state regarding handling of DPI settings. They can be either un-aware, system aware, per-monitor aware or the awareness might not be defined (kind of fourth option).

If WinForms application DPI-awareness has not defined in code or in application manifest or by some other means, the application is by default un-aware and DIP-PX (Device Independent Pixel / Screen Pixel) factor is 1 no matter what DPI settings is defined in windows. When the LightningChart is created it loads some WPF libraries and because of this the DPI awareness of the application is automatically changed to the WPF default of system aware, and the DIP-PX factor is changed to that defined by windows settings. After the chart is removed, the DPI-awareness is returned to original.

To counter this behaviour you must manually define the DPI-awareness of the application so that the WPF-libraries default setting will not affect the program. Note that the DPI-awareness does not have to be defined to System aware or per-monitor aware, but it can also be forced to un-aware to keep the default WinForms functionality.

Probably the easiest way to set the DPI awareness is by modifying (or adding) the application manifest and setting dpiAware to wished value, like in the following partial sample.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" a xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true/pm</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</asmv1:assembly>
More information about the DPI awareness can be found from MSDN https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
and about application manifests from https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Re: FormSizeChange in HighDPI PC

Posted: Wed Apr 27, 2016 9:09 am
by fukasawa
Thank you for your reply,

Everything work well! :mrgreen:

Re: FormSizeChange in HighDPI PC

Posted: Thu Feb 20, 2020 3:29 pm
by sam319
I believe this is the complete solution:
https://stackoverflow.com/questions/349 ... -awareness