I use the below code to manage different custom task panes in PowerPoint VSTO across presentations. This works fine, e.g. when a user opens a new presentation a new task pane is created and it does not affect any other open presentation task panes.
Now I encountered the following situation. A user has opened a presentation and now opens an additional window in PowerPoint for this presentation (click "View", "New window"). Now what happens is that a new custom task pane (because this window's HWND is different) is created but instead I need this task pane to be the same as in the other presentation window.
Question: how can I "share" a task pane between all windows of the same presentation?
Dim CreatedPanes As New Dictionary(Of String, CustomTaskPane)
Public Function GetTaskPane(taskPaneId As String, taskPaneTitle As String) As Microsoft.Office.Tools.CustomTaskPane
Dim key As String = $"{taskPaneId}({Globals.ThisAddIn.Application.HWND})"
If Not CreatedPanes.ContainsKey(key) Then
Dim pane = Globals.ThisAddIn.CustomTaskPanes.Add(New myTaskPaneControl(), taskPaneTitle)
CreatedPanes(key) = pane
End If
Return CreatedPanes(key)
End Function
I think the same logic will apply to Excel as well, hence I am sldo adding this tag to the question.