General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How to stop File – > Close or Window Close functionality when validation fails.

  • tsrsgm

    How to stop File – > Close or Window Close functionality when validation fails.

    Participants 4
    Replies 5
    Last Activity 12 years, 1 month ago

    Hi

    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,
    Sridhar

    Reply

    Derek Read

    Reply to: How to stop File – > Close or Window Close functionality when validation fails.

    You 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%20operations

    Reply

    tsrsgm

    Reply to: How to stop File – > Close or Window Close functionality when validation fails.

    Hi Derek,

    Thank you for reply. Could you please share some code snippet regarding the same.
    Thank you in advance.

    Sridhar

    Reply

    tsrsgm

    Reply to: How to stop File – > Close or Window Close functionality when validation fails.

    Hi 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,
    Sridhar

    Reply

    Derek Read

    Reply to: How to stop File – > Close or Window Close functionality when validation fails.

    You 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

    Reply

    tsrsgm

    Reply to: How to stop File – > Close or Window Close functionality when validation fails.

    Thank you for help Derek.

    I got the expected result.

    Regards,
    Sridhar

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support