- You need to check Visible property directly before you display the message. Also you can check property SilentOperation.
- Usually I use PromptMessage instead of MessageBox because it respects the SilentOperation automatically.
- Show any blocking UI during AddIn start is not good idea. If you want to inform user about anything when the AddIn starts, wait, until the application fully starts. Event OnReady and property Ready is good to determine if you want to display message directly or wait.
Incomplete sample of members mentioned above:
Class MyAddInServer
Implements ApplicationAddInServer
Private _applicationEvents As ApplicationEvents
Public Property ThisApplication As Inventor.Application
Private ActivateMessage As String
Public Sub Activate(addInSiteObject As ApplicationAddInSite, firstTime As Boolean) Implements ApplicationAddInServer.Activate
ThisApplication = addInSiteObject.Application
_applicationEvents = ThisApplication.ApplicationEvents
ActivateMessage = "Something you want to display to the user"
If ThisApplication.Ready Then
ShowMessage()
Else
AddHandler _applicationEvents.OnReady, AddressOf ApplicationEvents_OnReady
End If
End Sub
Private Sub ApplicationEvents_OnReady(beforeOrAfter As EventTimingEnum, context As NameValueMap, <Out> ByRef handlingCode As HandlingCodeEnum)
handlingCode = HandlingCodeEnum.kEventNotHandled
'Run event handler just once
RemoveHandler _applicationEvents.OnReady, AddressOf ApplicationEvents_OnReady
ShowMessage()
End Sub
Private Sub ShowMessage()
'Use PromptMessage instead of MessageBox
ThisApplication.CommandManager.PromptMessage(ActivateMessage, 0)
End Sub