DPI Change & Form Re-sizing in different views

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

DPI Change & Form Re-sizing in different views
 
Alex Carter




Posts: 37
Joined: 2019-02-21
Hi,
I have an ADX form that changes size dependent on the type of view an email is shown in. When in read mode it is collapsed to just show 1 control and when in compose mode the form is shown fully with all controls then set to visible. Please see below images:

Collapsed:
User added an image

Shown:
User added an image

I have added into the form some DPI changes & form size changes whenever the DPI changes:

    Private Const initFormHeight As Integer = 115
    Private Const initFormWidth As Integer = 904
    Private NewHeight = 115

    'Needs to match eFiles title init size.
    Private Const initAnyControlSizeHeight As Integer = 21
    Private Const initAnyControlSizeWidth As Integer = 214

    Private Sub RecalcSize()
        Width = Math.Round(txtEfileTitle.Width / initAnyControlSizeWidth * initFormWidth)
        Height = Math.Round(txtEfileTitle.Height / initAnyControlSizeHeight * initFormHeight)
        NewHeight = Height
    End Sub

    Private Sub UpdateDPI(ByVal root As Control, ByVal dpi As Integer, ByVal dpiFactor As Single)
        For Each cl As Control In root.Controls
            cl.Bounds = Rectangle.Round(New RectangleF(cl.Left * dpiFactor, cl.Top * dpiFactor, cl.Width * dpiFactor, cl.Height * dpiFactor))
            If cl.Controls.Count > 0 Then UpdateDPI(cl, dpi, dpiFactor)
            cl.Font = New Font(cl.Font.FontFamily, cl.Font.Size * dpiFactor, cl.Font.Unit)
        Next
    End Sub

    Private Sub eFilesAction_ADXDPIChanged(sender As Object, e As ADXDPIChangedEventArgs) Handles Me.ADXDPIChanged
        UpdateDPI(Me, e.DPI, e.DPIFactor)
        RecalcSize()
    End Sub


This seems to work OK but I have a problem when the monitor is set to use 150% scaling, the whole Outlook email gets screwed up when the view mode changes, please see below:

Collapsed:
User added an image

Expanded:
User added an image

Does anybody have any ideas why this is happening?

If necessary I can provide a full copy of the code behind the ADXForm/Project.

Thanks in advance,
Alex
Posted 13 Nov, 2019 05:16:17 Top
Alex Carter




Posts: 37
Joined: 2019-02-21
As an update this problem only seems to occur when composing the email as an inline response on the 150% scaled monitor. If I pop the window out and hit reply/forward etc, the issue does not occur. Also when I do an inline response on the 100% monitor it works absolutely fine.

Also if I scroll on the form left and right the controls all line up correctly on the form, however I am still stuck with the duplicated cc/bcc etc as below:

User added an image
Posted 13 Nov, 2019 05:27:28 Top
Andrei Smolin


Add-in Express team


Posts: 16814
Joined: 2006-05-11
Hello Alex,

Could you please create a simple project reproducing this issue?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Nov, 2019 04:56:36 Top
Alex Carter




Posts: 37
Joined: 2019-02-21
Hi Andre,
Yep I will get this over tomorrow morning for you.
Posted 14 Nov, 2019 12:04:10 Top
Alex Carter




Posts: 37
Joined: 2019-02-21
Hi Andre,
I have created an example project here: Code Download

I would say it looks like the issue is due to resizing of the form based on what controls are to be shown. When hitting reply on an email the first time when the form is already expanded, it displays correctly, however when discarding this and doing it again the issue occurs (this still only occurs on monitors scaled higher than 100% though.

Please let me know you thoughts.
Posted 15 Nov, 2019 04:17:42 Top
Alex Carter




Posts: 37
Joined: 2019-02-21
Morning Andrei,
Just wondering whether you have had a moment to look at this? I am struggling to work out how to fix the problem.

Cheers,
Alex
Posted 18 Nov, 2019 03:14:45 Top
Andrei Smolin


Add-in Express team


Posts: 16814
Joined: 2006-05-11
Good morning, Alex.

We are looking into the project.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Nov, 2019 03:20:52 Top
Andrei Smolin


Add-in Express team


Posts: 16814
Joined: 2006-05-11
Alex,

1. You shouldn't change the form size in the ADXDpichanged event.

2. Radio buttons, check boxes, group boxes (the list may be extended) are standard Windows controls and they cannot scale correctly when used in an Office application. Say, the check image in a check box controls is a picture taken from system library (comctl32.dll). There's no API to specify that this library uses images for a different DPI so we are unable to scale these controls. You have two ways: a) switch to using WPF (it can be scaled correctly); b) create a custom implementation of a check box, etc. or customize these control(s) if such a possibility exists (some controls allow custom drawing).

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Nov, 2019 04:06:08 Top
Alex Carter




Posts: 37
Joined: 2019-02-21
Hi Andrei,
Thanks for the update, I will try and switch to using WPF to get the scaling to work correctly on unscalable controls.

I have commented out the RecalcSize function in the form to stop adjustment when the DPI is changed. The issue still occurs where the Send/To section is duplicated above the actual Send/To section. I am actually using the ExplorerInlineResponseEx & ExplorerInlineResponseCloseEx events to change the form height accordingly to show/hide form fields.

Do you have any ideas on this?

Thanks,
Alex
Posted 18 Nov, 2019 04:25:59 Top
Andrei Smolin


Add-in Express team


Posts: 16814
Joined: 2006-05-11
Alex Carter writes:
Do you have any ideas on this?


We can't reproduce this.

What Outlook build are you using? See the complete version info located to the right of the About Outlook button (see File | Office Account).

What are the steps to reproduce the issue?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Nov, 2019 06:06:52 Top