Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top