Cancel an event SOLVED
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.
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.
Cancel an event
How can I cancel one of the before events? I want to cancel the save event.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2352
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Cancel an event
Hi, Espens.
You may handle "e.document.beforeSave" event:
HTH.
You may handle "e.document.beforeSave" event:
Code: Select all
OnEvent(LONG nEventID, IEvent *pEvent, IUnknown *pFrom)
{
if (nEventID == n_e_document_beforeSave)
{
// CComPtr<IPXV_Document> pDoc;
// pFrom->QueryInterface(&pDoc);
// CComPtr<IPXV_DocSaveEvent> pSaveEvt;
// pEvent->QueryInterface(&pSaveEvt);
pEvent->put_Result(S_FALSE); // cancel save
return;
}
}
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Cancel an event
Hi Vasyl,
regarding this topic and your reply I do have an addtional question. When I register to the "e.document.beforeSave" event how can I suppress UI messages from Pdf Editor like the save dialog (see attached file).
Martin
regarding this topic and your reply I do have an addtional question. When I register to the "e.document.beforeSave" event how can I suppress UI messages from Pdf Editor like the save dialog (see attached file).
Martin
- Attachments
-
- 2015-09-10_074101.zip
- (65.79 KiB) Downloaded 159 times
Last edited by MartinCS on Thu Sep 10, 2015 5:42 am, edited 1 time in total.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2352
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Cancel an event
Hi Martin.
Firstly, your screenshot-image is inaccessible(requires login). But, I guess you talking about "Ask for save doc before close" dialog. In this case - currently is no way to suppress it.
In the near future we will add easy method to suppress/override processing of our UI-commands.
Best
Regards.
Firstly, your screenshot-image is inaccessible(requires login). But, I guess you talking about "Ask for save doc before close" dialog. In this case - currently is no way to suppress it.
In the near future we will add easy method to suppress/override processing of our UI-commands.
Best
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Cancel an event
Hi Vasyl,
I wasn't aware that the screenshot needed a login. My intention was to use the "[img]" tag to create an inline image. But wasn't sure how to use it. I updated my last post by uploading the screenshot of the save dialog in a zip container.
Thank you for the information. I will wait and follow the version history (https://www.pdf-xchange.com/PDFXE_history.html) for the updated version to come.
Martin
I wasn't aware that the screenshot needed a login. My intention was to use the "[img]" tag to create an inline image. But wasn't sure how to use it. I updated my last post by uploading the screenshot of the save dialog in a zip container.
Thank you for the information. I will wait and follow the version history (https://www.pdf-xchange.com/PDFXE_history.html) for the updated version to come.
Martin
- Tracker Supp-Stefan
- Site Admin
- Posts: 17810
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Cancel an event
Hi Stefan,
regarding this topic I have an additional question in order to be able to cancel the close event.
I have the following code:
Register Pdf Editor events:
Handle Pdf Editor events:
The method 'PdfEditorEx.PdfEditorActiveDocBeforeClose' displays a custom user dialog with Yes, No and Cancel options (and some further internal business logic). However, what I'm finding is that regardless of the value (true, false) I set for e.pEvent.Handled, the event is not cancelled. This is resulting in documents being closed every time the event is triggered.
Is there something that I'm missing here, or is there a better way to handle a cancelled event?
Cheers,
Martin
regarding this topic I have an additional question in order to be able to cancel the close event.
I have the following code:
Register Pdf Editor events:
Code: Select all
this.pdfCtl.OnEvent += this.PdfCtl_OnEvent;
this.RegisterPdfEditorEvents();
...
private void RegisterPdfEditorEvents()
{
this.eventIdActiveDocBeforeClose = this.pdfCtl.Inst.Str2ID("e.document.beforeClose");
this.pdfCtl.EnableEventListening2(this.eventIdActiveDocBeforeClose, true);
}
Code: Select all
private void PdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
if (e.nEventID == this.eventIdActiveDocBeforeClose)
{
if (PdfEditorEx.PdfEditorActiveDocBeforeClose(e.pEvent, pdfDocumentModel) == DialogResult.Cancel)
{
e.pEvent.Handled = false // true;
//e.pEvent.Result = 1;
return;
}
}
}
Is there something that I'm missing here, or is there a better way to handle a cancelled event?
Cheers,
Martin
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2352
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Cancel an event
Hi Martin.
Please uncomment this line in your code and it will help you..
HTH
Code: Select all
//e.pEvent.Result = 1;
HTH
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Cancel an event
I already tried the following lines of code:
But it did not help me to stop the closing event.
I have a windows form which contains the pdf control. When the user clicks the close button (top right) of the windows form I close all opened pdf documents with:
This triggers the 'e.document.beforeClose' event which is handled by event id inside of the PdfCtl_OnEvent method.
My application is using a custom "save before close" dialog because I need communicate any changes to our backend system. In your earlier post you mentioned that the functionallity to suppress pdf editor UI dialogs will be implemented in the next release.
I believe that my code above is correct, but I do not understand why it is not working like I expect. I hope I was able to explain my use case, but if you require further explanation than please let me know and I would happy to oblige.
Code: Select all
if (e.nEventID == this.eventIdActiveDocBeforeClose)
{
if (PdfEditorEx.PdfEditorActiveDocBeforeClose(e.pEvent, pdfDocumentModel) == DialogResult.Cancel)
{
e.pEvent.Handled = false;
e.pEvent.Result = 1;
return;
}
}
I have a windows form which contains the pdf control. When the user clicks the close button (top right) of the windows form I close all opened pdf documents with:
Code: Select all
this.pdfCtl.Doc.Close();
My application is using a custom "save before close" dialog because I need communicate any changes to our backend system. In your earlier post you mentioned that the functionallity to suppress pdf editor UI dialogs will be implemented in the next release.
I believe that my code above is correct, but I do not understand why it is not working like I expect. I hope I was able to explain my use case, but if you require further explanation than please let me know and I would happy to oblige.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2352
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Cancel an event
Hi Martin.
The correct code:
You must pass 'AllowCancel' flag to Doc.Close(), otherwise the your current event-handling will be ignored...
HTH.
The correct code:
Code: Select all
private void pdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
if (e.nEventID == this.eventIdActiveDocBeforeClose)
{
if (PdfEditorEx.PdfEditorActiveDocBeforeClose(e.pEvent, pdfDocumentModel) == DialogResult.Cancel)
{
e.pEvent.Handled = true; // pass 'true' to notify editor that event is processed
e.pEvent.Result = 1; // pass non-zero number to stop of document closing process (ignored when Doc.Close() called without PXV_DocClose_AllowCancel flag)
return;
}
}
....
}
...
int closeFlags = (int)(PDFXEdit.PXV_DocCloseFlags.PXV_DocClose_AllowCancel);
this.pdfCtl.Doc.Close(closeFlags);
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Cancel an event
Hi Vasyl,
I wasn't aware of the PXV:PXV_DocCloseFlags (https://sdkhelp.pdf-xchange.com/vie ... CloseFlags).
It's all working now.
Thank you for help!
Martin
I wasn't aware of the PXV:PXV_DocCloseFlags (https://sdkhelp.pdf-xchange.com/vie ... CloseFlags).
It's all working now.
Thank you for help!
Martin
- Tracker Supp-Stefan
- Site Admin
- Posts: 17810
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact: