Page 1 of 1

Event when activeX control is fully initialized

Posted: Thu Jan 10, 2019 11:43 pm
by MartinCS
Hi Tracker team,

I do have a windows forms application (implemented with C#). The main form of the applications contains the AxPDFXEdit.AxPXV_Control. I also implemented some control events which are handled in the OnEvent method:

Code: Select all

private readonly Dictionary<int, Action> _viewerEvents = new Dictionary<int, Action>();

private void RegisterPdfEditorEvents()
{
    _viewerEvents.Add(pdfCtl.Inst.Str2ID("e.activeDocChanged"), Event_ActiveDocChanged);
    _viewerEvents.Add(pdfCtl.Inst.Str2ID("e.document.toolActivated"), Event_ActiveToolChanged);
    _viewerEvents.Add(pdfCtl.Inst.Str2ID("e.app.initialized"), () => _isFormCreated = true);

    foreach (var viewerEvent in _viewerEvents)
    {
        pdfCtl.EnableEventListening2(viewerEvent.Key, true);
    }
}

private void PdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
    Debug.WriteLine("pdfCtl.OnEvent: EventID=={0} / EventDisplayName=={1}", e.nEventID, pdfCtl.Inst.ID2Str(e.nEventID));

    if (_viewerEvents.TryGetValue(e.nEventID, out var action))
    {
        action();
    }
}
My problem is that the registered event for "e.app.initialized" is never triggered. I do get the other two events e.g. when a document is opened or the tool is changed by the user.

I also checked all other available events on: https://sdkhelp.pdf-xchange.com/vi ... PXV_Events

The event "e.app.initialized" seems to me to be the right event to wait until the activeX control is fully initialized. Unfortunately, it's not working. Do you guys have an advice?

I'm using build: 7.0.0327.0001

Cheers,
Martin

Re: Event when activeX control is fully initialized

Posted: Fri Jan 11, 2019 5:11 pm
by Sasha - Tracker Dev Team
Hello Martin,

From what I see, when these events are fired, the control itself does not listen to the OnEvent method. The control is fully initialized after the InitializeComponent method - then you can execute your actions.

Cheers,
Alex

Re: Event when activeX control is fully initialized

Posted: Mon Jan 14, 2019 7:35 am
by MartinCS
Hi Alex,

thank you for your reply and explanation.

If the Control is already initialised by the time that my Event Registration function is called, then why does the "e.app.initialized" event exist? It seems strange that there would be an event available in the SDK that I am unable to listen for… If there is a way to listen for this event, I would be grateful if you could tell me.

The reason I ask is that we have a technical requirement for our Sofware to recognise that the PDFEditor ActiveX Control is loaded, so that other Business Logic can be run in the background.


Cheers,
Martin

Re: Event when activeX control is fully initialized

Posted: Mon Jan 14, 2019 8:54 am
by Sasha - Tracker Dev Team
Hello Martin,

At the moment when that event is fired, the Control itself is not yet being registered as an Event handler. You can listen to that event, by creating a custom event handler and registering it for listening before the IPXV_Inst initialization happens. Though in your case, it's not what you need, as this is an IPXV_Inst initialization indication, not the IPXV_Control one - some IPXV_Control related code is being executed after that event.
To achieve what you need, you will have to wait for the InitializeComponent() method to execute itself - then the IPXV_Control is fully initialized and is ready for use.

Cheers,
Alex