XE11Delphi + TeeChart + High DPI

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

XE11Delphi + TeeChart + High DPI

Post by ulibru » Mon Dec 20, 2021 8:55 pm

I like to use TeeChart together with high DPI awareness.
I've found no document about it, also the help is not helpful.

So how to set up Teechart in a XE11 IDE environment correctly to get a correct display for different monitors and different user Windows scalings? Which actions are done automatically, which actions have to be done by programming.
Examples: font sizes, e.g. of legend, thickness of lines and all other stuff.

Is TeeChart aware about DPI settings?

BR
Uli

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: XE11Delphi + TeeChart + High DPI

Post by Yeray » Wed Dec 22, 2021 8:54 am

Hello,

Yes, TeeChart should be DPI aware. Find here a discussion and a test project about the subject.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

Re: XE11Delphi + TeeChart + High DPI

Post by ulibru » Tue Jan 18, 2022 11:49 am

Hello Yeray,

please let me come back to the high DPI question.

Here is the DisplaySize example with a checkbox in the legend. The snapshot is taken from a 300% scaling on a high DPI monitor.

DisplaySize.png
DisplaySize.png (102.49 KiB) Viewed 15925 times
As you can see the checkbox is far from usable. Also the icons in the bar get unreadable. The images do not properly scale.

In a setup with 2 screens with different resolutions the program should be aware about the change of scaling and/or resolution (shift of GUI between monitors). Therefore the program or here better chart must get information about a change.
Possible you do this by the ChangeScale procedure as mentioned in https://www.steema.com/support/viewtopi ... 188#p78188

But by the DisplaySize example the setting of the font sizes is just by a button click and not an automatic reaction on a screen scaling.
And as the example shows the checkboxes are not touched in any way.

Any idea for a solution?

Best wishes
Uli

ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

Re: XE11Delphi + TeeChart + High DPI

Post by ulibru » Thu Jan 20, 2022 11:55 am

Hello Yeray,

do you have any answer for my DPI problem (legend checkboxes)?

Best wishes
Uli

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: XE11Delphi + TeeChart + High DPI

Post by Yeray » Thu Jan 20, 2022 11:59 am

Hello Uli,

The "Set all fonts" button in the DisplaySize example was an attempt to find a workaround when I wasn't able to find a proper ChangeScale implementation. However, that last code should work fine when moving a chart between screens with different scales.

I'll revise the legend checkbox and the commander icons. Doesn't the rest of the chart adapt correctly to the scale changes for you with that ChangeScale implementation?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

Re: XE11Delphi + TeeChart + High DPI

Post by ulibru » Thu Jan 20, 2022 12:41 pm

A simple line series with pen width = 1 gets very thin on a high DPI monitor. So actually I try to help myself by Pen.Width := nominal_pen_width * Screen.PixelsPerInch / 96 as a quick turnaround.
But again it shows that TeeChart is not consistent regarding High DPI.
As I only see my application I cannot tell you about all the obstacles. So you may need to check the library more deeply.
I expect from time to time to stumble across a next problem ;)

Best wishes
Uli

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: XE11Delphi + TeeChart + High DPI

Post by Yeray » Thu Jan 20, 2022 5:42 pm

Hello Uli,
Yeray wrote:
Thu Jan 20, 2022 11:59 am
I'll revise the legend checkbox and the commander icons.
I've already corrected the legend checkboxes at #2501.
ulibru wrote:
Thu Jan 20, 2022 12:41 pm
A simple line series with pen width = 1 gets very thin on a high DPI monitor. So actually I try to help myself by Pen.Width := nominal_pen_width * Screen.PixelsPerInch / 96 as a quick turnaround.
It doesn't look bad for me at 150%:
VirtualBoxVM_2022-01-20_18-30-33.png
VirtualBoxVM_2022-01-20_18-30-33.png (44.05 KiB) Viewed 15900 times
But you could try to override the ChangeScale method and change the series pen width there.
ulibru wrote:
Thu Jan 20, 2022 12:41 pm
But again it shows that TeeChart is not consistent regarding High DPI.
As I only see my application I cannot tell you about all the obstacles. So you may need to check the library more deeply.
I expect from time to time to stumble across a next problem ;)
Yes, I'm afraid we haven't tested all the possibilities and there are chances that we are missing something.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

Re: XE11Delphi + TeeChart + High DPI

Post by ulibru » Fri Jan 21, 2022 1:28 pm

Hello Yeray,

1.
great to read about the fix but where do I get it?

2.
How to override ChangeScale? I'm reluctant to change library source codes as with a next library update the problems start ... (is the update a solution or not, do I need to change my own code ... ?)

Best wishes
Uli

ulibru
Newbie
Newbie
Posts: 54
Joined: Tue Jul 21, 2009 12:00 am

Re: XE11Delphi + TeeChart + High DPI

Post by ulibru » Fri Jan 21, 2022 1:31 pm

Addendum: take a look at a a line of pen width = 1 on a monitor with resolution 3840 * 2160 ;)

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: XE11Delphi + TeeChart + High DPI

Post by Yeray » Wed Jan 26, 2022 8:13 pm

Hello,

We're in contact with Uli by mail, but I'd like to reply here in case other customers find this.
ulibru wrote:
Fri Jan 21, 2022 1:28 pm
great to read about the fix but where do I get it?
The fix is included in TeeChart v2022.34 published yesterday.
ulibru wrote:
Fri Jan 21, 2022 1:28 pm
How to override ChangeScale? I'm reluctant to change library source codes as with a next library update the problems start ... (is the update a solution or not, do I need to change my own code ... ?)
See TControl.ChangeScale at docwiki. Sice TForm inherits TControl, you can override it and change whatever you want there. Ie:

Code: Select all

type
  TForm1 = class(TForm)
  //...
  private
    procedure ChangeScale(M, D: Integer{$IFDEF D24}; isDpiChange: Boolean{$ENDIF}); override;

//...

procedure TForm1.ChangeScale(M, D: Integer{$IFDEF D24}; isDpiChange: Boolean{$ENDIF});
var i:  Integer;
begin
  inherited;

  if not (csLoading in Self.ComponentState) and (M <> D) then
  begin
    for i:=0 to Chart1.SeriesCount-1 do
      Chart1[i].Pen.Width:=MulDiv(Chart1[i].Pen.Width, M, D);
  end;
end;
ulibru wrote:
Fri Jan 21, 2022 1:31 pm
Addendum: take a look at a a line of pen width = 1 on a monitor with resolution 3840 * 2160 ;)
I have a fix proposal on the works.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply