Allow closing document without asking to save changes ("override" IsDirty)  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

Allow closing document without asking to save changes ("override" IsDirty)

Post by zarkogajic »

Hi Support,

How do I let the user close the altered ipxv_document without the message box asking the user to save changes (or no or cancel) being displayed.

I can catch the e.document.beforeClose and in it I can set pEvent.Handled to true and provide a non zero Result -> this stops the action from being executed - i.e. cancels the closing action (so document remains open).

I need a way to allow closing the document without asking the user about saving changes.

I guess once the e.document.beforeClose is executed, your internal code looks for IPXC_DocSrcInfo.IsDirty and (if it is) you call the "do you want to save changes..." message dialog. So if I could somehow "fool you" and set IsDirty = false the doc will close without any questions asked :)

-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by Vasyl-Tracker Dev Team »

You may try to close document silently using the e.document.beforeClose + pEvent.Handled=true and with the direct doc.Close(0) call inside your handler...
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.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Allow closing document without asking to save changes ("override" IsDirty)  SOLVED

Post by zarkogajic »

Hi Vasyl,

Thanks.

This is actually what I am doing at the moment (though I need to "postpone" closing until events are processed)

I was hoping there's a "better" approach :)


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

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by zarkogajic »

Hi (future readers)

Well, there is a better way :)

(ipxv) Document.SetModified(false, Document.ModificationLevel)

This will mark the document as not modified (even if it is) and it will be closed without asking the user to save changes.

-žarko
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by Tracker Supp-Stefan »

Hello zarkogajic,

Thanks for posting the above! Indeed it might be useful for others as well in the future!
Please be careful with this flag though!

Kind regards,
Stefan
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by zarkogajic »

Hi Stefan,

"Be careful"

Can you provide more info ?

p.s.
Of course, I will not use that for any other purpose.

-žarko
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by Tracker Supp-Stefan »

Hello zarkogajic,

I mean - to not inadvertently supress that flag in cases where it could result in the users losing data :)

Kind regards,
Stefan
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Allow closing document without asking to save changes ("override" IsDirty)

Post by zarkogajic »

Hi Stefan

Users are overrated ;)

Post Reply