Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've verified that the WM_SHOWWINDOW handler OnShowWindow() is not
called when ShowWindow is called with SW_SHOWMAXIMIZED. I created a
dummy MFC app (doc/view and no doc/view) and reproduced the behavior.
So, here is what I have (simplified)...

MFC app with no doc/view support.

CMyWinApp::InitInstance()
{
...
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
...
}

CMainFrame::OnShowWindow(...)
{
// Not called when m_nCmdShow == SW_SHOWMAXIMIZED!!
}

This seems to be the designed behavior. Does anyone know why? What
message can I handle in this case to know when the window is shown on
screen?
Posted
Comments
Sergey Alexandrovich Kryukov 5-Mar-14 1:31am    
Please do CodeProject search with most recent answers on top. I recently saw a very similar question.
—SA

Please read the MSDN documentation on WM_SHOWWINDOW.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632645%28v=vs.85%29.aspx[^]

SQL
The WM_SHOWWINDOW message is not sent under the following circumstances:

*  When a top-level, overlapped window is created with the WS_MAXIMIZE or WS_MINIMIZE style.
*  When the SW_SHOWNORMAL flag is specified in the call to the ShowWindow function.
 
Share this answer
 
I just tried this with an MFC SDI application and it does call CMainFrame::OnShowWindow when using m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
You could also create a handler for WM_SIZE (CMainFrame::OnSize) to do your processing although it would be called multiple times.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900