3

Is it possible for the the main application window to detect a WM_CLOSE event when a modal dialog is active?. If not, is there any way of detecting the WM_CLOSE event because the event handler for the dialog does not detect it either.

To observe this behaviour for yourself, open the 'about' menu of notepad and then right-click on the notepad icon in the taskbar and select the 'close window' option, it will have no effect.

Does anyone know of a way to catch a WM_CLOSE event for an application when a modal window is active?

alk
  • 69,737
  • 10
  • 105
  • 255
Gearoid Murphy
  • 11,834
  • 17
  • 68
  • 86

1 Answers1

3

When selecting "close" by right-clicking an application's icon in the task bar no WM_CLOSE is sent.

What happens is that the application's main window is sent a WM_SYSCOMMAND with wParam set to SC_CLOSE.

For an example on how to exploit this "feature" please see my other answer on this here.

Community
  • 1
  • 1
alk
  • 69,737
  • 10
  • 105
  • 255