Alex Carter
Posts: 67
Joined: 2019-02-21
|
Hi Guys,
I have an ADX form which has 3 buttons along the top, these are always shown wherever you are in an outlook mail message. Then I have the rest of the form which is only shown when composing an email (reply/new mail). I am able to dynamically change the height of my form using this code:
Private Sub EmailAutoFilingHost_ADXBeforeFormShow() Handles Me.ADXBeforeFormShow
Dim inspector As Outlook.Inspector = CType(Me.InspectorObj, Outlook.Inspector)
HideFields()
If inspector IsNot Nothing Then
Dim Item As Object = inspector.CurrentItem
If TypeOf Item Is Outlook.MailItem Then
Dim mail As Outlook.MailItem = CType(Item, Outlook.MailItem)
If Not mail.Sent Then
ShowFields()
Dim Subject As String = mail.Subject
OcisViewable = am.CasecodeViewableLookup(Subject)
End If
End If
If Item IsNot Nothing Then Marshal.ReleaseComObject(Item)
End If
DoBackgroundPaint()
End Sub
Public Sub ShowFields()
RegionState = ADXRegionState.Hidden
Me.ClientSize = New System.Drawing.Size(1054, 96)
Me.ElementHost1.Size = New System.Drawing.Size(1054, 96)
AutoFilingForm1.ShowFields()
RegionState = ADXRegionState.Normal
End Sub
Public Sub HideFields()
RegionState = ADXRegionState.Hidden
Me.ClientSize = New System.Drawing.Size(1054, 25)
Me.ElementHost1.Size = New System.Drawing.Size(1054, 25)
AutoFilingForm1.HideFields()
RegionState = ADXRegionState.Normal
End Sub
For this to work correctly when Outlook loads up, I have to set the initial form height to 25 which is fine for inline emails. The problem I have is when an email is "popped out" into a separate inspector. The height stays at 25 and does not correctly adjust up to 96 as expected. Is there any advice on how to get this to function correctly? Would there be a different event I need to use?
As always, any advice is greatly appreciated! |
|
Andrei Smolin
Add-in Express team
Posts: 18965
Joined: 2006-05-11
|
Hello Alex,
Your code allows both HideFields and ShowFields to be called in a succession. Try to change the logic so that only HideFields or ShowFields method is called.
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|
Alex Carter
Posts: 67
Joined: 2019-02-21
|
Thanks Andre,
I've added an else clause to the If block to call HideFields only when required however this doesn't resolve the issue.
When the email initially opens in the popped out state, all fields are correctly hidden and height is set correctly. However, when clicking the reply button, fields are shown but the height does not expand up as expected. |
|
Andrei Smolin
Add-in Express team
Posts: 18965
Joined: 2006-05-11
|
Hello Alex,
I've reproduced this. I'll ask our guys to debug this and get back to you; supposedly, this will occur before the weekend.
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|
Andrei Smolin
Add-in Express team
Posts: 18965
Joined: 2006-05-11
|
Hello Alex,
Here's what I found.
1. The manual says:
Resizing form
There are two values of the <Item>.Splitter property. The default one is Standard. This value shows the splitter allowing the user to change the form size as required. The form size is saved to the registry so that the size is restored whenever the user starts the host application.
You can only resize your form programmatically if you set the Splitter property to None. This prevents the user from resizing the form. Changing the Splitter property at run time does not affect a form currently loaded into its region (that is, having Visible = true). Instead, it will be applied to any newly shown form.
2. Use the ADXAfterFormShow event.
3. Note that setting RegionState to Hidden and then to Normal doesn't make sense. These operations are asynchronous in their nature.
Here's the actual code I used:
Private Sub EmailAutoFilingHost_ADXAfterFormShow() Handles MyBase.ADXAfterFormShow
Dim inspector As Outlook.Inspector = CType(Me.InspectorObj, Outlook.Inspector)
System.Diagnostics.Debug.Print("!!! EmailAutoFilingHost_ADXAfterFormShow 1")
If inspector IsNot Nothing Then
Dim Item As Object = inspector.CurrentItem
If TypeOf Item Is Outlook.MailItem Then
Dim mail As Outlook.MailItem = CType(Item, Outlook.MailItem)
If Not mail.Sent Then
System.Diagnostics.Debug.Print("!!! EmailAutoFilingHost_ADXAfterFormShow 2")
ShowFields()
Else
System.Diagnostics.Debug.Print("!!! EmailAutoFilingHost_ADXAfterFormShow 3")
HideFields()
End If
End If
If Item IsNot Nothing Then Marshal.ReleaseComObject(Item)
End If
System.Diagnostics.Debug.Print("!!! EmailAutoFilingHost_ADXAfterFormShow 4")
End Sub
Public Sub ShowFields()
Me.Height = 196
End Sub
Public Sub HideFields()
Me.Height = 125
End Sub
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|