DPI scaling issue

Add-in Express™ Support Service
That's what is more important than anything else

DPI scaling issue
Issue with dialog scaling when AddinExpress.Outlook.Regions using 
Andriy


Guest


Hello guys,

We use AddinExpress.Outlook.Regions to show several panels in outlook. And now we are working with DPI scaling support.

The issue is that after showing panels with AddinExpress.Outlook.Regions we lose functionality for dialogues auto scaling per monitor(Case when user have multiple monitors with diferent DPI).

We have tryied to set system DPI aware for thread that shows the dialogs, but looks lite it works incorrectly.

SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);


With this aproach dialogs start scale, but appears wird effects: Black borders around the dialogues, issue with dialogs which use SizeToContent, incorrect interaction with some control: ComboBoxs, Popups(Example adding shows that user cant normaly select item in comboBox). All this effects disappear after disabling AddinExpress.Outlook.Regions panels.

How we can use AddinExpress.Outlook.Regions and keep embeded dialogs scaling?
By the links below you can download the example to reproduce the issue (It demonstarate only issue with combobox), also by the links below you can find screens of the other issues:
https://drive.google.com/file/d/1wp2lCfrnDI8gUhPTjtMz2pJEqXD0uAti/view?usp=sharing
https://drive.google.com/file/d/136F4DT6LBY-j7p6XOG0ctfct4VbQzCTR/view?usp=sharing
https://drive.google.com/file/d/17M_w75yCZ9Xf9_lfmjXze1twrKLwW7Sb/view?usp=sharing
https://drive.google.com/file/d/1KoaZGc-HPlBhR-WEOc2crAt-4KqPMzXD/view?usp=sharing
Posted 16 Oct, 2020 08:40:55 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Andriy,

Andriy writes:
We have tryied to set system DPI aware for thread that shows the dialogs


Instead, you should pass it the context returned by GetWindowDpiAwarenessContext(outlookMainWindow); get outlookMainWindow via GetActiveWindow(); this is Win API.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Oct, 2020 04:05:08 Top
Andriy


Guest


Hi again, thank for the help.

We are facing another issue with scaling in Add-in express header.

1. We get Add-in Express header bounds in our override OnDrawHeader method.
2. We get Graphics object from ContainerControl.CreateGraphics() and can pain whole header red for example.

The problem is that when bounds scaled only part of header is colored. It looks Graphics.VisibleClipBounds shows us smaller are then it should be for drawing.

Can you help us scale our header?
Posted 23 Oct, 2020 09:18:09 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Andriy,

See the DrawArgs parameter of the OnDrawheader() method. It provides Graphics and Bounds.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Oct, 2020 03:36:19 Top
Andriy


Guest


Hello,

I can use OnDrawHeader() method when the corresponding event is raised. But I need to get current Graphics object from ContainerControl at other moment of time, when header has already been drawn.

When my monitor scaling is default (100% in my case) then ContainerControl.CreateGraphics() works properly. But if scaling is changed (to 150%, for example) then ContainerControl.CreateGraphics() returns Graphics with reduced VisibleClipBounds.

Is it possible get Graphics object with correct VisibleClipBounds as OnDrawHeader() provides, but beyond the OnDrawHeader() method?
Posted 29 Oct, 2020 08:33:48 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Andriy,

You should use OnDraw as the header may be absent. This method is called whenever the container us draw; we think this method suits any need.

As far as we can see Graphics (and GDI+) doesn't work correctly with multiple DPIs. It works correctly with the DPI of the main monitor. When you use Graphics on another monitor, you'll still get information on the main monitor and you graphics won't draw correctly.

Andriy writes:
Is it possible get Graphics object with correct VisibleClipBounds as OnDrawHeader() provides, but beyond the OnDrawHeader() method?


No. We can't control it.


Andrei Smolin
Add-in Express Team Leader
Posted 29 Oct, 2020 09:54:34 Top