General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › How to stop File – > Close or Window Close functionality when validation fails.
-
tsrsgm October 18, 2010 at 5:51 am
How to stop File – > Close or Window Close functionality when validation fails.
October 18, 2010 at 5:51 amParticipants 4Replies 5Last Activity 12 years, 5 months agoHi
In my application, i need to do some validation when user choose File -> Close or Window Close in the XMetal. If the validation fails it returns false, then the Document should not be closed, else then let the window/document closed. Could u pls suggest some work around of this issue. Thanks a lot in advance.
Thanks,
SridharDerek Read October 18, 2010 at 8:12 am
Reply to: How to stop File – > Close or Window Close functionality when validation fails.
October 18, 2010 at 8:12 amYou will likely need to override the File > Close and File > Exit functionality to do this.
Have a look at the Programmers Guide topic titled “File operations”.
http://na.justsystems.com/webhelp/en/xmetaldeveloper/pg/6.0/pg.html#File%20operationstsrsgm October 18, 2010 at 9:41 am
Reply to: How to stop File – > Close or Window Close functionality when validation fails.
October 18, 2010 at 9:41 amHi Derek,
Thank you for reply. Could you please share some code snippet regarding the same.
Thank you in advance.Sridhar
tsrsgm October 18, 2010 at 11:01 am
Reply to: How to stop File – > Close or Window Close functionality when validation fails.
October 18, 2010 at 11:01 amHi Derek,
In my application we are using “On_Document_Close” macro, when i choose File -> Close or window Close this macro being called. Please let me know the code snippet i should put in this macro. So that the document should not be closed after performing the certail validations.
Thanks,
SridharDerek Read October 18, 2010 at 9:48 pm
Reply to: How to stop File – > Close or Window Close functionality when validation fails.
October 18, 2010 at 9:48 pmYou cannot stop a document from closing in the event On_Document_Close as the close process has already begun.
In order to stop a document from closing you will need to override the File > Close action. See “File operations” as I have previously noted.
When you override that action a document will not close unless you specifically tell it to close. In the table for that help topic you will see the APIs you need to call to give you the “default” behavior for the action. If you do not call the API then the default behavior will never occur (and in this case the user will never be able to close a document).
In your case your logic might be something like this:
1) Do validation or whatever else you like to obtain a result of some kind.
2) Create a boolean based on that result.
3) Do an if...then type of check on the boolean. Perhaps something similar to this:if (bool_allowDocumentToClose = true) then
ActiveDocument.Close()
else (bool_allowDocumentToClose = false) then
Application.Alert("Sridhar says: You cannot close this document because...")
end if -
AuthorPosts
- You must be logged in to reply to this topic.