Yes, I tried using two different global variables as shown below, uncommenting only ONE "If" statement at a time in OnHistoryUpdated. Neither of them worked. The code was ALWAYS executed, even when displaying a chart.
Thus, I am assuming that a global variable is also seen by PSM code.
Not sure how else to code this kind of check.
Class UserEntryFormHandler
public Function OnMenuItemSelected ( id )
If (id <> G_MenuUserEntryForm) Then
Exit Function
Else
G_MyScript = "Update 1-Share Transactions"
G_Myid = id
End If
...
...
End Function
public Function OnFormSubmitted ( form )
...
End Function
public Function UpdateForm ( Process )
...
GetHistoryData ticker, HistoryStartDate, HistoryEndDate, HistoryRecs, HistoryPrice, HistoryRecNo, G_HistoryDataError
...
End Function
public Function GetHistoryData ( ticker, HistoryStartDate, HistoryEndDate, HistoryRecs, HistoryPrice, HistoryRecNo, rtnCode )
...
ticker.DownloadHistoryData HistoryStartDate, HistoryEndDate
...
End Function
public Function OnHistoryUpdated ( ticker )
' If this OUR script extension ...
If G_MyScript = "Update 1-Share Transactions" Then
' If (G_Myid = G_MenuUserEntryForm) Then
MsgBox "OnHistoryUpdated for ticker: " & ticker.Symbol, vbOKOnly, "Test"
' MsgBox "Got downloaded history data for " _
' & ticker.GetProperty("Symbol"), vbOKOnly, "Test"
Else
MsgBox "OnHistoryUpdated - Not my script code.", vbOKOnly, "Test"
End If
End Function
' Dimension global variables ...
Dim G_MyScript
Dim G_Myid
End Class ' (UserEntryFormHandler)
' Initialization (executed at PSM run) ...
Set EventManager = Application.GetObject("EventManager")
Set MenuManager = Application.GetObject("MenuManager")
Set FormHandler = new UserEntryFormHandler
' Register our event handlers (executed at PSM run) ...
If Not EventManager Is Nothing Then
EventManager.RegisterHandlerMethod FormHandler, "OnMenuItemSelected"
EventManager.RegisterHandlerMethod FormHandler, "OnHistoryUpdated"
Else
' Could not get EventManager object ...
' MsgBox "Could not get EventManager object.", vbOKOnly, "Test"
End If