帮助:窗口打开SW_SHOWMAXIMIZED时处理WM_SHOWWINDOW [英] HELP: Handling WM_SHOWWINDOW when window opened SW_SHOWMAXIMIZED
问题描述
我已经验证了当使用SW_SHOWMAXIMIZED调用ShowWindow时,WM_SHOWWINDOW处理程序OnShowWindow()不是
。我创建了一个
虚拟MFC应用程序(doc / view,没有doc / view)并重现了这个行为。
所以,这就是我所拥有的(简化)......
没有文档/视图支持的MFC应用程序。
CMyWinApp :: InitInstance()
{
...
pMainFrame->的ShowWindow(m_nCmdShow);
pMainFrame-> UpdateWindow();
...
}
CMainFrame :: OnShowWindow(...)
{
//当m_nCmdShow == SW_SHOWMAXIMIZED时未调用!!
}
这似乎是设计行为。有谁知道为什么?在这种情况下我可以处理什么
消息来知道窗口何时显示在
屏幕上?
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?
推荐答案
请阅读WM_SHOWWINDOW上的MSDN文档。
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632645%28v=vs.85%29.aspx [< a href =http://msdn.microsoft.com/en-us/library/windows/desktop/ms632645%28v=vs.85%29.aspxtarget =_ blanktitle =New Window> ^ ]
Please read the MSDN documentation on WM_SHOWWINDOW.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632645%28v=vs.85%29.aspx[^]
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.
我刚刚尝试使用MFC SDI应用程序,当使用m_pMainWnd-> ShowWindow时它会调用
CMainFrame :: OnShowWindow
(SW_SHOWMAXIMIZED);
您还可以为WM_SIZE
创建处理程序(CMainFrame :: OnSize
)进行处理虽然会被多次调用。
I just tried this with an MFC SDI application and it does callCMainFrame::OnShowWindow
when usingm_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
You could also create a handler forWM_SIZE
(CMainFrame::OnSize
) to do your processing although it would be called multiple times.
这篇关于帮助:窗口打开SW_SHOWMAXIMIZED时处理WM_SHOWWINDOW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!