I'm catching WindowProc and looking for WM_SYSCOMMAND / SC_MINIMIZE, but it only fires the message when I minimize the window by clicking in its taskbar icon.
When I click in the window's minimize button the message isn't fired.
switch (Msg)
{
case WM_SYSCOMMAND:
switch (wParam)
{
case SC_MINIMIZE:
{
OutputDebugStringW(L"Window minimized!");
//return TRUE;
}
}
break;
}
I noticed that my window was not sending the WM_SIZE message, then while searching i have found this:
By default, the DefWindowProc function sends the WM_SIZE and WM_MOVE messages to the window. The WM_SIZE and WM_MOVE messages are not sent if an application handles the WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient to perform any move or size change processing during the WM_WINDOWPOSCHANGED message without calling DefWindowProc.
I confirmed that its sending WM_WINDOWPOSCHANGED when i try to minimize by clicking in the minimize button.
case WM_WINDOWPOSCHANGING:
tagWINDOWPOS * wp = reinterpret_cast<tagWINDOWPOS *>(lParam);
wp->x = ...;
wp->y = ...;
wp->cx = ...;
wp->cy = ...;
LPARAM lp = reinterpret_cast<LPARAM>(wp);
I have tried to set x, y, cx, cy values to the current ones, but the window still got minimized.