When tree control is added to the pane is disappears from the form

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

When tree control is added to the pane is disappears from the form
 
Sergey Chizh




Posts: 71
Joined: 2012-10-23
Hi.

This is continuation of the https://www.add-in-express.com/forum/read.php?FID=5&TID=15994. For some reason I can't add new comments to it.
Anyway, the problem is still present for some PCs, and we added log to your code hoping to understand the reason.

Public Shared Function SetThreadDPIContext(ByVal contextWindow As IntPtr) As Integer
AddinModule.TrackDPI("Entered SetThreadDPIContext(ByVal contextWindow As IntPtr)")
Dim oldContext As Integer = CInt(DPIAwarenessContext.UnAware)
AddinModule.TrackDPI("OldContext default: " & oldContext)
AddinModule.TrackDPI("IsSupported: " & IsSupported)
If IsSupported Then
oldContext = _getThreadDpiAwarenessContext()
AddinModule.TrackDPI("Get oldContext: " & oldContext)
Dim dpiContext As Integer = _getWindowDpiAwarenessContext(contextWindow)
AddinModule.TrackDPI("Get dpiContext: " & dpiContext)
If oldContext <> dpiContext Then
AddinModule.TrackDPI("Now calling: _setThreadDpiAwarenessContext(dpiContext)")
_setThreadDpiAwarenessContext(dpiContext)
End If
End If

Return oldContext
End Function


The log for highlighted bold line returns zero. And it when the problem occurs. Does it says anything to you? Thanks!

22-01-2021 11:14:25 : Calling Engine-> SetThreadDPIContext from StartWizard
22-01-2021 11:14:25 : Entered SetThreadDPIContext(ByVal contextWindow As IntPtr)
22-01-2021 11:14:25 : OldContext default: -1
22-01-2021 11:14:25 : IsSupported: True
22-01-2021 11:14:25 : Get oldContext: 24593
22-01-2021 11:14:25 : Get dpiContext: 0
22-01-2021 11:14:25 : Now calling: _setThreadDpiAwarenessContext(dpiContext)
22-01-2021 11:14:37 : Called SetThreadDPIContext from SaveToDocunoteExplorerRibbonButton_OnClick
22-01-2021 11:14:37 : Entered SetThreadDPIContext(ByVal contextWindow As IntPtr)
22-01-2021 11:14:37 : OldContext default: -1
22-01-2021 11:14:37 : IsSupported: True
22-01-2021 11:14:37 : Get oldContext: 24593
22-01-2021 11:14:37 : Get dpiContext: 18
Posted 22 Jan, 2021 06:33:21 Top
Andrei Smolin


Add-in Express team


Posts: 17630
Joined: 2006-05-11
Hello Sergey,

There's a window in which your pane is created; you can get that window's HWND using e.g. the GetActiveWindow() WinApi method.

Right before you add that control onto the pane (I assume you do this at the run time, say as a reaction to some event), you compare the DPI context of the thread (oldThreadDpiContext) with the DPI context of the window (windowDpiContext): if they don't match, you set the DPI context of the thread to windowDpiContext.

I've tried to download the project but I don't have permissions (?)

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jan, 2021 07:04:07 Top
Sergey Chizh




Posts: 71
Joined: 2012-10-23
Hello Andrey,

We do not add controls to the form in runtime; we simply open modal form after click on Add-In button and some controls on this form are invisible. Our code is nearly the same as was recommended by you in our previous issue:

Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles TestButton.OnClick
DPIAwareAPI.SetThreadDPIContext(WinAPI.GetActiveWindow())
'here we create and open new modal form
End Sub

Your DEMO project http://temp.add-in-express.com/support/OutlookAddInTest.zip from https://www.add-in-express.com/forum/read.php?FID=5&TID=15994 is still available, it works fine in our development environment, but when we released project with the same logic we received lots of complains from our customers as they still see form without controls.
We are not able to reproduce this problem, we only managed to get some logged information from PCs on which controls are not shown.
Could you please help us to understand why DPIAwareAPI.SetThreadDPIContext(WinAPI.GetActiveWindow()) does not work on some PCs.
Posted 22 Jan, 2021 09:41:58 Top
Andrei Smolin


Add-in Express team


Posts: 17630
Joined: 2006-05-11
Hello Sergey,

Sorry for the delay; I need to discuss this with our guys.

We would like to have a code example that reproduce this issue for you.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 28 Jan, 2021 02:19:42 Top