AcadDocument_BeginClose Event

Discussion in 'AutoCAD' started by weslleywang, Sep 21, 2004.

  1. weslleywang

    weslleywang Guest

    Hi:
    I have 2 question:
    1. In my AcadDocument_BeginClose Event function, I will check what my customer did, if they do something, I will ask them to quit closing and run certain command to update. right now I do not know how to quit closing in Begin_Close.
    2. when you close the drawing, a dialog box: Do you want to save drawing with 3 buttons: Save/No/Cancel show up. How do I know which button my user clicked?


    If any one know the solution, I really appreciate your help. Thank you very much.



    Wes
     
    weslleywang, Sep 21, 2004
    #1
  2. weslleywang

    weslleywang Guest

    Hi:
    This is what I found after research:
    I can not cancel Close command in Begin event.
    I tried Begin, not work either. it still show the Save/No/Cancel dialog box. What I am thinking is, is there any way I can send a press on Cancel button, which will cancel the close command. Is this possible ?



    Thank you very much?


    West
     
    weslleywang, Sep 21, 2004
    #2
  3. weslleywang

    TomD Guest

    box. What I am thinking is, is there any way I can send a press on Cancel
    button, which will cancel the close command. Is this possible ?

    I do not believe it is. As I understand it, you cannot stop any event from
    happening.

    Possible solution:

    Have the BeginClose event throw up an option where the user can decide
    whether or not to update the data you are interested in.
     
    TomD, Sep 21, 2004
    #3
  4. Hi,

    have a look at the BeginQuit event. You may from within this event cancel
    exiting AutoCAD. BeginQuit is triggered before BeginClose. BeginClose giv
    you a chance to do some cleaning before AutoCAD closes, but it is to late to
    prevent it to do so.

    Gilles
     
    Gilles Plante, Sep 23, 2004
    #4
  5. weslleywang

    TomD Guest

    Have you tried this? I'm not suggesting it won't work, but I remember
    reading in a VBA book (Bill Kramer's, I think) that you cannot stop any
    event from happening, though for certain events you can create the
    appearance that they did not happen. If that's true, you wouldn't be able
    to stop the Quit from happening.
     
    TomD, Sep 23, 2004
    #5
  6. Yes I did. Extract from the Help file:

    -----------
    object.BeginQuit (Cancel)object

    Application
    An object expression that evaluates to a valid container object. In this
    case, the only valid container is the application.

    Cancel

    Boolean; output from the handler

    TRUE: Aborts the shutdown of AutoCAD.

    FALSE: Allows the shutdown of AutoCAD to continue.

    ---------

    As you can see, I don't have any trick im my hat. This event makes it
    possible to cancel Quit by design

    Gilles
     
    Gilles Plante, Sep 23, 2004
    #6
  7. weslleywang

    TomD Guest

    Kewl. Thank you much for clarifying.
     
    TomD, Sep 23, 2004
    #7
  8. weslleywang

    weslleywang Guest

    Hi Gilles:
    Thank you for your help.
    I tried BeginQuit, it works, but on Application level, not Document level which I am looking for. It only get trigged when AutoCAD close. It will not get trigged when current drawing close. I would like current drawing keeping open until all problem get fixed.
    Do you have any idea about this?



    Thank you a lot for pointing the new event.
    Have a great weekend.


    Wes
     
    weslleywang, Sep 24, 2004
    #8
  9. West,

    sorry for pointing in the wrong direction. The only thing coming to my mind
    would be to have a procedure "in front of" the AutoCAD provided CLOSE
    command. This would work this way:

    1- You write a front end CustomClose procedure that would do the necessary
    step needed before closing the drawing. You ask what to do to the user with
    MsgBox(). Then you invoke for the actual CLOSE command via Document.Close

    2- In order for your function to be invoked by menu choices, you have two
    choices:

    a) Modify the menu to call your function instead of the CLOSE command.
    But then there is also Window > Close All

    b) You redefine the CLOSE command in LISP to call you own version

    I prefer b), because you don't need to edit the menu and it is easier to do.
    And if your .DVB/LISP is not loaded, AutoCAD behaves as usual !

    Gilles

    level which I am looking for. It only get trigged when AutoCAD close. It
    will not get trigged when current drawing close. I would like current
    drawing keeping open until all problem get fixed.
     
    Gilles Plante, Sep 27, 2004
    #9
  10. Hi Gilles,
    I hate to throw another spanner in the works but what about the X in the titlebar.
    Regards - Nathan
     
    Nathan Taylor, Sep 28, 2004
    #10
  11. Nathan,

    the X on the title bar generates a Quit. If the drawing is not saved,
    something you can check, I guess it will call the CLOSE command. The other X
    simply calls the CLOSE command.

    It is because there are so many ways to close the drawing that it is better
    to go with replacing the CLOSE command with a custom.

    Gilles
     
    Gilles Plante, Sep 28, 2004
    #11
  12. Hi Gilles

    Have you tried it? When I undefine the close command the X on the document titlebar still closes the drawing and I would suggest redefining the close command would make absolutely no difference.

    The reason I tested it is that I would like to redefine the save commands and yes the simple option is to redefine QSAVE, SAVE & SAVEAS but a similar problem exists where AutoCAD will still prompt the user to save a drawing and use the standard command.

    Regards - Nathan
     
    Nathan Taylor, Sep 29, 2004
    #12
  13. Nathan,

    no I did not try it, and I trapped myself ! The X on the document title bar
    does not invoke the CLOSE command. But there is hope... I discovered this
    morning an event I overlooked. From the online documentation:

    ------

    object.BeginDocClose(Cancel)
    object

    Document object
    An object expression that evaluates to a valid container object. In this
    case, the only valid containers are the application and a document.

    Cancel

    Boolean
    Determines whether to prevent the drawing from being closed.

    TRUE: The drawing is prevented from closing.

    FALSE: The drawing is not prevented from closing.

    Remarks

    You can use this event to keep a drawing from being closed. This event
    should be used instead of the BeginClose event.

    No events occur while a modal dialog is being displayed.

    -----

    Looks like what Wesley is looking for. In this event, if something has to
    be done, simply set cancel to True, and warn the user.

    Wesley, are you still reading the thread ? Unfortunetaly, there is no way to
    email him directly.

    Gilles

    titlebar still closes the drawing and I would suggest redefining the close
    command would make absolutely no difference.
    and yes the simple option is to redefine QSAVE, SAVE & SAVEAS but a similar
    problem exists where AutoCAD will still prompt the user to save a drawing
    and use the standard command.
     
    Gilles Plante, Sep 29, 2004
    #13
  14. weslleywang

    weslleywang Guest

    Yes, This is one I am looking for. I will try it as soon as I have time and let everybody know what I found.

    Thank you so much, Gilles
    Wes
     
    weslleywang, Sep 29, 2004
    #14
  15. weslleywang

    thenrich Guest

    The 'X' of an AutoCAD document does not fire the close event handler - the 'X' is more a standard windows process. There is no way to stop the quit through conventional means. The only way possible is to use API and check windows messages - and that's iffy...
     
    thenrich, Sep 29, 2004
    #15
  16. Seems odd that they have a BeginClose and BeginDocClose. I assume the BeginDocClose was introduced later on with the extra functionality so as not to break existing code.
    Regards - Nathan
     
    Nathan Taylor, Sep 30, 2004
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.