I like to get some clarifications here
I have added a menu option 'Enter SQC Comment' underneath 'Show Details and Annotations'
Are you using the PI SQC Automation Interface Example on "Alarm and Comments"? or you are adding a new menu option yourself?
Question #2: How do I know the tag and the timestamp of the Alarm selected?
"Alarm selected" meaning the value the mouse pointer is pointing to before you go into the right-click menu?
The SQC Alarm Source tag can be retrieved in VBA using the SQCSymbol.GetTagname(1) method.
I have moved this thread into the ProcessBook/ActiveView and Microsoft Office Development forum, since it seems to be more related to VBA and ProcessBook Environment, rather than PI SDK =)
To answer your first question: I have added a new menu option. I am not using the PI SQC Automation Interface Example.
To answer your second question: Yes, the pointer is pointing to an SQC Alarm value. I will try SQCSymbol.GetTagname(1) to retrieve the tag. How do I retrieve the timestamp? SQCSymbol.GetTimestamp(1)?
We can attach events handler to a new menu item programmatically. I'm not too sure you are doing this in VBA or writing an Add-in to do this, but here's a sample for VBA:
Dim WithEvents cbtn As PBCommandBarButton
' insert custom option to Context Display Menu (right-click menu) when display opens
Private Sub Display_Open()
Dim contextmenubar As PBCommandBar
Set contextmenubar = Application.CommandBars("Context Display Menu")
Dim m_contextbtn As PBCommandBarButton
' reset Context Display Menu to default
' add in new button on menu '
Set m_contextbtn = contextmenubar.Controls.Add(pbControlType.pbControlButton, 1, Null, Null, False)
m_contextbtn.Caption = "Add SQC Comments"
' attach an event to the button
Set cbtn = m_contextbtn
' task to execute when button_click event is captured.
Sub cbtn_click(ByVal btn As PBCommandBarButton, ByRef b As Boolean)
MsgBox "Add SQC Comment"
I haven't been able to figure out a way to find the time on a trend or an SQC chart based on the mouse pointer position, a quick workaround would be to insert a cursor onto the SQC chart and you can do something like the following to get the time, value and alarm status (true or false only)
Private Sub SQCSymbol1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
I'll check out with the developer and see if they have any suggestion for getting the time according to the mouse pointer position as well