(推荐这个方法,非常好用)
很多人可能会将窗口创建出来,然后用一个 ShowWindow(SW_HIDE) 的方法去隐藏窗口,当然这是可以做到隐藏的功能,但是有一点不足的地方就是窗口在隐藏之前会有一下短瞬的闪烁,而以下这种方法可以解决这种问题:
在 C***App::InitInstance() 的函数中将以下的这一段注释掉:
C***Dlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
换成:
C***Dlg *dlg = new C***Dlg;
m_pMainWnd = dlg;
return dlg->Create(IDD_***_DIALOG);
同时将 IDD_***_DIALOG 的对话框资源属性页的 Visible 属性的勾去掉即可。