Preventing a document from closing in BeforeCloseDoc event

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Preventing a document from closing in BeforeCloseDoc event

Post by DanielG »

Hello,

I am trying to cancelling the closing of a document within Notifications.BeforeCloseDoc in OnEvent, but I can't seem to figure it out.

I've tried running calling SetProperty on Notifications.BeforeCloseDoc.Cancel, passing in a value of 1, but the document still closes.

I also tried setting DataOut of OnEvent to 1, but that doesn't work either.

How do I prevent a document from closing in the BeforeCloseDoc event?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Preventing a document from closing in BeforeCloseDoc eve

Post by Vasyl - PDF-XChange »

Hi, Daniel.
I've tried running calling SetProperty on Notifications.BeforeCloseDoc.Cancel, passing in a value of 1, but the document still closes.
Please be sure that you changed the "Cancel" property inside your OnEvent procedure:

Code: Select all

youreventhandler OnEven(type, name...)
{
     if ((type == PXCVA_OnNamedNotify) AND (name == "Notifications.BeforeCloseDoc"))
     {
           int docID = 0; 
           pdfViewer.GetProperty(name + ".DocID", out docID);
           if (ConditionToPreventCloseDoc(docID))
           {
                pdfViewer.GetProperty(name + ".Cancel", 1);
           }
     } 
}
HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Re: Preventing a document from closing in BeforeCloseDoc eve

Post by DanielG »

Thanks for the information. I believe the method used should be SetProperty (not GetProperty). When I use SetProperty, it works. :mrgreen:
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7361
Joined: Wed Mar 25, 2009 10:37 pm

Re: Preventing a document from closing in BeforeCloseDoc eve

Post by Paul - PDF-XChange »

:)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Preventing a document from closing in BeforeCloseDoc eve

Post by Vasyl - PDF-XChange »

Sure, the SetProperty instead of GetProperty must be used, sorry for my auto-mistake. :oops:
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.