Handling events e.document.beforeClose / e.document.closed  SOLVED

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
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Handling events e.document.beforeClose / e.document.closed

Post by zarkogajic »

Hi support,

I need to get notified when a document is closed in the pxv_control's Frame/View, and I need to know the Frame/View of where the document was.

[Q1] If I go with "e.document.closed" event - how do I get to the Frame (/View) of the document that is closed? The ActiveView is null at this moment and I cannot use GetMainViewFromUIObj(doc.ActiveView.obj), where doc is IPXV_Document(pFrom).

[Q2] If I go with "e.document.beforeClose" then I can get to the Frame/View - but I'm not sure if the action (closing the document) can be stopped (outside of the event handler)? I need to be 100% sure that a document will be closed once I handle this event.

[Q3] Further, setting "pEvent.Handled = true" for "e.document.beforeClose" does not stop the document from closing (only stops the event from being propagated to other frames). In what event can I do this - stop document from closing?

[Q4] What is pEvent in both events?


-žarko
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Handling events e.document.beforeClose / e.document.closed

Post by zarkogajic »

Hi,

To answer part of my question: I've decided to store a reference to the MainView and IPXV_Document in the e.document.beforeClose, then in the e.document.closed if the document matches the one stored, I know that document is closed (and I know its MainView - so where the document was since I do not allow moving the document in between frames/views).

The remaining 2 questions still stay: how can I stop a document from being closed?

I've tried custom handling the "cmd.close" command but it seems I cannot stop the close operation there.

Also, the cmd.close does not get executed when closing a document by its tab's close button, or "close active tab" button - so how to handle those also?
image.png
-žarko
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Handling events e.document.beforeClose / e.document.closed  SOLVED

Post by zarkogajic »

:)

Ok, found it. To stop a document from closing, handle the e.document.beforeClose and specify something for the pEvent.Result value.

Case closed.

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Handling events e.document.beforeClose / e.document.closed

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: Handling events e.document.beforeClose / e.document.closed

Post by prasantha »

zarkogajic wrote: Tue Oct 29, 2019 10:07 am :)

Ok, found it. To stop a document from closing, handle the e.document.beforeClose and specify something for the pEvent.Result value.

Case closed.


Hi ,
I tried the to stop closing the pdf as you have mentioned . I used the below code snippet in side e.document befoe closing event.
e.pEvent.Result = 1;
e.pEvent.Handled = true;
But it continue the execution and it fires the e.documetn_closed event and close the document.
Can you please let me know what I have misssed here?

Thank you
prasantha
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Handling events e.document.beforeClose / e.document.closed

Post by zarkogajic »

Hi,

"Works for me" :)

What is the value of pEvent.Param1 ?

For me it is 1 (am not sure what it really means), but the SDK help states it must not be 0 for event breaking to be allowed: https://sdkhelp.pdf-xchange.com/vi ... eforeClose

p.s.
How are you closing the document?

-žarko
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: Handling events e.document.beforeClose / e.document.closed

Post by prasantha »

HI žarko,

Than k you for you response.
Its 1 for pEvent.Param1.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17820
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Handling events e.document.beforeClose / e.document.closed

Post by Tracker Supp-Stefan »

:)
Post Reply