29

I occasionally get the error that Word gives when trying to close a document with another dialogue box open but I've never been able to figure out why it happens.

  • 6
    The general issue is that stuff in the dialog might become valid, invalid, or even inapplicable depending on what you do in the main window, and there's often no clear way to resolve this with changes that the user might have made in the dialog in the interim. (I guess this is just another manifestation of the more general principle of "feedback loops can cause problems in a system".) – user541686 Mar 9 '18 at 4:30
  • They can if you launch Task Manager and tell it to kill the process. =) But this may have unexpected side effects. (There might be some rare instances where a file could end up corrupted, but I'm pretty sure they'd be extremely rare. It has to be designed for unanticipated crashes and power outages anyway.) – jpmc26 Mar 9 '18 at 23:55
62

Because most dialog boxes are considered "modal" which means that control does not pass back to the main program, or calling container, until the dialog itself is closed. This is by design and the programmer has the option to make a window modal or non-modal. Usually, a window is defined to be modal if the main program cannot or should not continue until the opened dialog is dealt-with either through selection (Ok) or aborting (Cancel).

  • 4
    But if the dialog were modal, how did the OP instruct the program to close? Might something else be going on here? – Lightness Races in Orbit Mar 8 '18 at 23:55
  • 7
    @LightnessRacesinOrbit There are many ways of closing a program, not all of which require clicks on the main window. For instance, you can right-click on a taskbar entry and select "Close", or pull Task Manager up with Ctrl-Shift-Esc and attempt to close from there. Shutting down Windows will also attempt to close applications gracefully initially, although may then "kill" them after a timeout. These send a signal to the program to close without it actually having focus, hence Bob's screenshot saying "Click OK, switch to Word" in that order. – IMSoP Mar 9 '18 at 16:57
  • @IMSoP: I am aware that there are more "engineering" ways to ask an application to close, but I'd mentally drawn a line where I think "common usage" ends, because I'd have expected the OP to specify exactly what they were doing if it were beyond "common usage". – Lightness Races in Orbit Mar 9 '18 at 17:10
  • 11
    @LightnessRacesinOrbit I grant you Task Manager is a more "expert" way, but I wouldn't be at all surprised if people thought closing something from the taskbar was perfectly normal. In fact, I now realise, you don't even need to right-click, there's a red [x] button right there if you hover over a group or view the little thumbnail. Different things seem obvious to different people. – IMSoP Mar 9 '18 at 17:20
  • @IMSoP: That is true. – Lightness Races in Orbit Mar 9 '18 at 17:26
20

The dialog box might be saying something like:

You have made changes to your document, do you want to save them? (Yes) (No)

There is no obvious right answer here. You may have accidentally corrupted your document (for example, the cat walked over the keyboard) in which case the answer is "No", or you might have spent hours typing in changes in which case the answer is "Yes".

The safest thing for Word to do is is refuse to close until you answer the question.

  • 9
    I'm pretty sure the question is about this error specifically. – Bob Mar 9 '18 at 5:48
  • 12
    OK, but the question didn't mention any particular dialog box. I'm a programmer, I understand what a modal dialog box is, however I tried to answer the question of why it happens. – Nick Gammon Mar 9 '18 at 6:25
  • IMHO gotta keep in mind that people who aren't programmers use programs. – LawrenceC Mar 11 '18 at 15:15
1

Because the program is designed this way, to avoid taking action the user might not want.

Usually, a dialog box is displayed when the program needs the user to guide some action. Closing an unsaved document is excellent example: a dialog offers to save the changes, discard the changes or abort closing and return to editing. The program intentionally refuses to close without answering this question because closing will force SOME action to be taken. The program can't decide on it's own to eg. discard recent edit, or on the contrary, overwrite correct version with cat-on-the-keyboard typing.

Even if we consider a dialog that's not related to closing, it usually means that some process is underway, it hadn't completed yet, and the user must decide which way to go. It cannot be "simply aborted", because aborting is also an action that the user might not meant.

It also simplifies design of the program, as it's creators don't have to create "a safe way out" of every function.

Today, most dialogs are not modal in the technical sense (the program remains responsible), but it's still easier to make them modal in a wider sense of logic flow of the program.

0

I could be mistaken, but I suspect this goes back to the old common dialog control behavior.

Several of those if killed abruptly without returning had unpleasant side effects, sometimes even outside the now-dead program and there was not a way to escape from them politely in all cases if they were doing something at a system level that required user input.

As to why it still is that way, people grew used to it, developers programmed with that assumption for decades and more importantly non-programmers used those dialogs in their office automation scripts and Microsoft is nothing if not a strict adherent to the goals backwards compatibility.

0

Behind the curtains, the program (in our case it's MS Word) creates a "X button click event handler" when creating the window. When there's a dialog window, Word records that. Then, in the X button handler, when the X button clicked, it checks for recorded open dialog windows. If there are some, the handler aborts the close operation. If there are not, it terminates the program and the OS cleans up the memory taken by the program. This is how it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.