Event when activeX control is fully initialized

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Event when activeX control is fully initialized

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Event when activeX control is fully initialized

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Event when activeX control is fully initialized

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Event when activeX control is fully initialized

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply