Home Image-Pro Automation (Macros, Apps, Reports)

No Activation Event fired when clicking through open images

Hi there, 
with several images open, I want to track which one is currently the active image. But McApplication.SelectedDataChanged only fires on deactivating an image (Flags parameter is always 255). The same happens with the McImage-Events. The Activate-Event doesn't fire, only the Deactivate-Event.

Private Sub _application_SelectedDataChanged(Flags As MediaCy.IQL.Application.IMcData.DataTypes) Handles _application.SelectedDataChanged
    ' ONLY FIRES WHEN LEAVING AN IMAGE
    myImg = _application.ActiveImage
    Debug.Print(myImg.Name)
End Sub

Private Sub myImg_Deactivate(Image As McImage) Handles myImg.Deactivate
'FIRES ON LEAVING THE IMAGE
    Debug.Print(myImg.Name) 
End Sub

Private Sub myImg_Activate(Image As McImage) Handles myImg.Activate
'NEVER FIRES
    Debug.Print(myImg.Name)
End Sub
Can anyone direct me how to solve the problem.

I want to automatically run code on the active image once the user has clicked into another image.

Thank you.
Regards,
Helga

Best Answer

Answers

  • edited August 8
    Thanks Yuri,

    the Windows events work perfectly for my purpose.

    I was misled by the sample addin code (PremierAddin3.zip) which suggests that the _application.SelectedDataChanged event reflects the image that is the ActiveImage. In reality, what is meant to be the active image is actually the image that was the active image!

    But still, I'm glad I know better now.

    Best regards,
    Helga
     
        ''' <summary>
        ''' Handles document activation in the application.
        ''' </summary>
        ''' <param name="Flags"></param>
        ''' <remarks></remarks>
        Private Sub _application_SelectedDataChanged(Flags As MediaCy.IQL.Application.IMcData.DataTypes) Handles _application.SelectedDataChanged
            ' Sample code to display active document
            If _application.ActiveDocument Is Nothing Then
                Me.Label1.Text = "Active Document is Nothing"
            Else
                Me.Label1.Text = "Active Document is " & _application.ActiveDocument.DisplayName
            End If
        End Sub

Sign In or Register to comment.