Anshul Dutt
Posts: 68
Joined: 2007-10-24
|
Hi,
I pretty new to Add-in express. I am using Add-in express for VSTO. I am trying to programmatically figure out where the reading pane is located in outlook(2003).
If its at the right or bottom or if its turned off. Is there a way to figure this out programmatically?
following is as close as I got:
OutlookApp.ActiveExplorer.CommandBars("View").Controls("Reading Pane")
after this I am not sure how to get the values for Right/bottom/Off.
Then, Depending on the Reading pane's location I want to set the Custom ADX form's(pane) location to BottomReadingPane(when reading pane is set to "right") and to RightReadingPane when the the reading pane is set to "Bottom".
following is what I have so far:
Private Sub AdxCommandBarButton1_Click(ByVal sender As Object) Handles AdxCommandBarButton1.Click
Dim OutlookApp As New Outlook.Application
If AddinExpress.OL.ADXOlReadingPaneLayout.Bottom Then 'not sure what to compare this to
Me.AdxOlFormsManager1.Items(0).ExplorerLayout = AddinExpress.OL.ADXOlExplorerLayout.RightReadingPane
ElseIf AddinExpress.OL.ADXOlReadingPaneLayout.Right Then
Me.AdxOlFormsManager1.Items(0).ExplorerLayout = AddinExpress.OL.ADXOlExplorerLayout.BottomReadingPane
ElseIf AddinExpress.OL.ADXOlReadingPaneLayout.Off Then
Me.AdxOlFormsManager1.Items(0).ExplorerLayout = AddinExpress.OL.ADXOlExplorerLayout.RightSubpane
End If
end sub
any help would be greatly appreciate it.
Thanks in advance. |
|
Anshul Dutt
Posts: 68
Joined: 2007-10-24
|
We decided to go with a different approach, so wouldn't need to figure out the user selected opton for the reading pane.
but would be curious to know if someone knows how to retrieve those options programmatically.
Thanks. |
|
Fedor Shihantsov
Add-in Express team
Posts: 1188
Joined: 2005-01-11
|
Hello Anshul,
You can use the following code to get a reading/preview pane's location:
Public Shared Function ReadingPaneLayout(ByVal ExplorerObj As Object) As AddinExpress.OL.ADXOlReadingPaneLayout
Try
Dim CommandBarsObj As Object = Nothing
Dim ReadingPaneButton As Object = Nothing
Dim ReadingPaneCommandBar As Object = Nothing
Dim RightButton As Object = Nothing
Dim BottomButton As Object = Nothing
Dim OffButton As Object = Nothing
Try
CommandBarsObj = ExplorerObj.[GetType]().InvokeMember("CommandBars", System.Reflection.BindingFlags.GetProperty, Nothing, ExplorerObj, New Object() {})
If CommandBarsObj IsNot Nothing Then
ReadingPaneButton = CommandBarsObj.[GetType]().InvokeMember("FindControl", System.Reflection.BindingFlags.InvokeMethod, Nothing, CommandBarsObj, New Object() {10, 31134})
End If
If ReadingPaneButton IsNot Nothing Then
ReadingPaneCommandBar = ReadingPaneButton.[GetType]().InvokeMember("CommandBar", System.Reflection.BindingFlags.GetProperty, Nothing, ReadingPaneButton, New Object() {})
End If
If ReadingPaneCommandBar IsNot Nothing Then
Dim state As Integer = 0
RightButton = ReadingPaneCommandBar.[GetType]().InvokeMember("FindControl", System.Reflection.BindingFlags.InvokeMethod, Nothing, ReadingPaneCommandBar, New Object() {1, 7221})
If RightButton IsNot Nothing Then
state = Convert.ToInt32(RightButton.[GetType]().InvokeMember("State", System.Reflection.BindingFlags.GetProperty, Nothing, RightButton, New Object() {}))
If state = -1 Then
Return AddinExpress.OL.ADXOlReadingPaneLayout.Right
End If
End If
BottomButton = ReadingPaneCommandBar.[GetType]().InvokeMember("FindControl", System.Reflection.BindingFlags.InvokeMethod, Nothing, ReadingPaneCommandBar, New Object() {1, 7222})
If BottomButton IsNot Nothing Then
state = Convert.ToInt32(BottomButton.[GetType]().InvokeMember("State", System.Reflection.BindingFlags.GetProperty, Nothing, BottomButton, New Object() {}))
If state = -1 Then
Return AddinExpress.OL.ADXOlReadingPaneLayout.Bottom
End If
End If
OffButton = ReadingPaneCommandBar.[GetType]().InvokeMember("FindControl", System.Reflection.BindingFlags.InvokeMethod, Nothing, ReadingPaneCommandBar, New Object() {1, 7223})
If OffButton IsNot Nothing Then
state = Convert.ToInt32(OffButton.[GetType]().InvokeMember("State", System.Reflection.BindingFlags.GetProperty, Nothing, OffButton, New Object() {}))
If state = -1 Then
Return AddinExpress.OL.ADXOlReadingPaneLayout.Off
End If
End If
End If
Finally
If CommandBarsObj IsNot Nothing Then
Marshal.ReleaseComObject(CommandBarsObj)
End If
If ReadingPaneButton IsNot Nothing Then
Marshal.ReleaseComObject(ReadingPaneButton)
End If
If ReadingPaneCommandBar IsNot Nothing Then
Marshal.ReleaseComObject(ReadingPaneCommandBar)
End If
If RightButton IsNot Nothing Then
Marshal.ReleaseComObject(RightButton)
End If
If BottomButton IsNot Nothing Then
Marshal.ReleaseComObject(BottomButton)
End If
If OffButton IsNot Nothing Then
Marshal.ReleaseComObject(OffButton)
End If
End Try
Return AddinExpress.OL.ADXOlReadingPaneLayout.Off
Catch e As Exception
Throw e
End Try
End Function
I recommend you use the ADXOlFormsManager events to get current Reading Pane/Preview state:
Private ReadingPaneStateByFormsManager As AddinExpress.OL.ADXOlReadingPaneLayout = AddinExpress.OL.ADXOlReadingPaneLayout.Off
Private Sub AdxOlFormsManager1_ADXReadingPaneHide(ByVal sender As System.Object, ByVal args As AddinExpress.OL.ReadingPaneHideEventArgs) Handles AdxOlFormsManager1.ADXReadingPaneHide
ReadingPaneStateByFormsManager = AddinExpress.OL.ADXOlReadingPaneLayout.Off
End Sub
Private Sub AdxOlFormsManager1_ADXReadingPaneMove(ByVal sender As System.Object, ByVal args As AddinExpress.OL.ReadingPaneMoveEventArgs) Handles AdxOlFormsManager1.ADXReadingPaneMove
ReadingPaneStateByFormsManager = args.ReadingPaneLayout
End Sub
Private Sub AdxOlFormsManager1_ADXReadingPaneShow(ByVal sender As System.Object, ByVal args As AddinExpress.OL.ReadingPaneShowEventArgs) Handles AdxOlFormsManager1.ADXReadingPaneShow
ReadingPaneStateByFormsManager = args.ReadingPaneLayout
End Sub
|
|
Anshul Dutt
Posts: 68
Joined: 2007-10-24
|
Hi Fedor,
This is exactly what I was looking for.I was able to get the location of the reading pane using your code.
Thanks a lot for your help.
|
|