FormSizeChange in HighDPI PC

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

FormSizeChange in HighDPI PC

Post by fukasawa » Mon Apr 25, 2016 5:43 am

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 10075 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 10075 times
3. Button2Clicked, Chart is Cleared in Panel.
FormSize and Location become normal.
3-button2Clicked.png
3-button2Clicked.png (29.24 KiB) Viewed 10075 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

User avatar
ArctionPasi
Posts: 1366
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: FormSizeChange in HighDPI PC

Post by ArctionPasi » Mon Apr 25, 2016 4:18 pm

Hi Fukasawa,

Our support personnel will answer you soon.
LightningChart Support Team, PT

User avatar
ArctionLasse
Posts: 26
Joined: Fri Mar 27, 2015 11:23 am

Re: FormSizeChange in HighDPI PC

Post by ArctionLasse » Tue Apr 26, 2016 2:04 pm

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
LightningChart Support Team, LV

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Re: FormSizeChange in HighDPI PC

Post by fukasawa » Wed Apr 27, 2016 9:09 am

Thank you for your reply,

Everything work well! :mrgreen:

sam319
Posts: 1
Joined: Thu Feb 13, 2020 11:41 am

Re: FormSizeChange in HighDPI PC

Post by sam319 » Thu Feb 20, 2020 3:29 pm

I believe this is the complete solution:
https://stackoverflow.com/questions/349 ... -awareness