Vetoing QUIT in AutoCAD

By Philippe Leefsma

Q:

How can I veto quit in AutoCAD?

A:

There are two situations to consider:

1) Subclass the AutoCAD main frame and watch for WM_CLOSE message. This message is generated when user tries to quit AutoCAD using any of the possible methods. In the sample, we veto the quitting of AutoCAD, but this can be modified to make changes in the documents, save them and then allow AutoCAD to quit. This way you can avoid the save dialog while quitting AutoCAD.

2) Using the event AcApDocManagerReactor::documentLockModeChanged() to trap the EXIT command that the user can issue at command prompt.

The attached arx sample implements both approaches.


Comments

3 responses to “Vetoing QUIT in AutoCAD”

  1. langshanglibie Avatar
    langshanglibie

    Hi, Philippe Leefsma!
    When I used the first method, and when I inputed “quit” at command prompt the second time,
    //windows proc function
    LRESULT CALLBACK fWndProc(HWND hwnd, UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
    // Handle the WM_CLOSE message and return true to veto the message
    // this stops AutoCAD from closing
    if(uMsg == WM_CLOSE)
    {
    acutPrintf(L”\nQuit Canceled…”);
    return true;
    }
    // Send all the messages you receive to AutoCAD so they can be handled as normal
    return ::CallWindowProc(wndProc,hwnd,uMsg,wParam,lParam);
    }
    I can’t received the WM_CLOSE message, I saved the current document in commandWillStart() in my MyEditorReactor derived from AcEditorReactor. Why this happend?

  2. Hi,
    Sorry, so far I do not reproduce the behavior. I am testing under 2014. What version and platform are you using? Are you using the exact same code that is provided in the attachment? What does “commandWillStart” have to do with the workflow?

  3. langshanglibie Avatar
    langshanglibie

    Thanks, Philippe!
    I have resolved my problem using all my skills, experiences, and tricks.
    Best wishes for you!

Leave a Reply to langshanglibieCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading