views:

83

answers:

0

In my application I catch exceptions using an exceptionfilter, then show a MessageBox telling the user that the application has crashed and giving him some additional information. I use a MessageBox instead of an explicitly constructed dialog because I want to minimize the logic executed after a crash.

Initially I had the problem that if the user went out to lunch while the application showed the MessageBox, the database sessions were kept open, data was locked, and other users could not access the data. See http://stackoverflow.com/questions/3091300/messagebox-with-timeout-or-closing-a-messagebox-from-another-thread. I finally solved that problem by simply exiting the application while the other thread still showed the MessageBox.

However, now I notice that if an application is exited while it still shows a MessageBox (in another thread), that the MessageBox is still shown after the process has gone (used Process Explorer to verify this). Apparently, a MessageBox is not owned by the process itself, but by a process called CSRSS.

The MessageBox is shown using the following call:

::MessageBox(0, m_text, m_title,
             MB_ICONHAND|MB_TOPMOST|MB_SETFOREGROUND|MB_OK|MB_TASKMODAL);

This is the first time I see this; therefore the following questions:

  • Is this a standard Windows behavior?
  • Is this supported functionality on Windows XP, Vista, Windows 7? (only tested on XP and W7)
  • Is this caused by giving the MessageBox a NULL owner (first argument)?
  • Or is this caused by making the MessageBox task modal (MB_TASKMODAL flag)?

Thanks.