基于对话框的应用,想要在启动时隐藏起来,该如何做?在OnInitDialog()中用ShowWindow(SW_HIDE);不行
可以在WM_WINDOWPOSCHANGING消息中处理:
LRESULT CYourDialog::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if(message == WM_WINDOWPOSCHANGING)
{
WINDOWPOS FAR* lpwndpos = (WINDOWPOS FAR*)lParam;
if (lpwndpos->flags & SWP_SHOWWINDOW)
{
lpwndpos->flags &= ~SWP_SHOWWINDOW;
PostMessage(WM_WINDOWPOSCHANGING, 0, (LPARAM)lpwndpos);
ShowWindow(SW_HIDE);
}
}
return CDialog::DefWindowProc(message, wParam, lParam);
}