D
David Taylor
I have a question about the lifetime of member variables in ThisDocument.
I'm trying to develop a solution which has its own custom menu (using
CommandBars to create the menu). In ThisDocument, I have two private member
variables mApp (Application) and m_mnuHeap (CommandBarPopup). In the
DocumentOpened event, I assign mApp to the global Application object, create
the custom menu, and assign mnuHeap to the menu. I sink the
Application.WindowActivated event with the following code:
Private Sub mApp_WindowActivated(ByVal Window As IVWindow)
If Window.Document Is ThisDocument Then
mnuHeap.Visible = True
Else
mnuHeap.Visible = False
End If
End Sub
The idea being to turn off the custom menu if the newly activated window
doesnt belong to ThisDocument, which works fine when I switch TO a new
document. However, when I try to switch BACK to my document, mnuHeap is
undefined. So, at some point the mnuHeap variable is destroyed. I find this
very strange, since mApp is not also destroyed (as evidenced by the event
firing!). Any ideas?
Thanks
Dave Taylor
PERI
I'm trying to develop a solution which has its own custom menu (using
CommandBars to create the menu). In ThisDocument, I have two private member
variables mApp (Application) and m_mnuHeap (CommandBarPopup). In the
DocumentOpened event, I assign mApp to the global Application object, create
the custom menu, and assign mnuHeap to the menu. I sink the
Application.WindowActivated event with the following code:
Private Sub mApp_WindowActivated(ByVal Window As IVWindow)
If Window.Document Is ThisDocument Then
mnuHeap.Visible = True
Else
mnuHeap.Visible = False
End If
End Sub
The idea being to turn off the custom menu if the newly activated window
doesnt belong to ThisDocument, which works fine when I switch TO a new
document. However, when I try to switch BACK to my document, mnuHeap is
undefined. So, at some point the mnuHeap variable is destroyed. I find this
very strange, since mApp is not also destroyed (as evidenced by the event
firing!). Any ideas?
Thanks
Dave Taylor
PERI