CGetTimeD lg *dlg;然后在InitInstance()中将原来的: 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 } 以及return FALSE;全部删除掉,改为: dlg=new CGetTimeDlg; m_pMainWnd = dlg; return dlg->Create(IDD_GETTIME_DIALOG); 最后别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框 变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退 出了,要用DestroyWindow()。 另外将对话框的属性设置为不可见(取消框中more styles 下的visible) 由于在上面的代码中没有将对话框设为可见,所以运行时就实现了隐藏,而且在Window s任务栏上也没有显示。
首先在CGetTimeApp类中添加一个成员变量:CGetTimeD lg *dlg;然后在InitInstance()中将原来的: 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 } 以及return FALSE;全部删除掉,改为: dlg=new CGetTimeDlg; m_pMainWnd = dlg; return dlg->Create(IDD_GETTIME_DIALOG); 最后别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框 变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退 出了,要用DestroyWindow()。 另外将对话框的属性设置为不可见(取消框中more styles 下的visible) 由于在上面的代码中没有将对话框设为可见,所以运行时就实现了隐藏,而且在Window s任务栏上也没有显示。
this->ShowWindow(SW_HIDE);
ShowWindow(SW_MINIMIZE);
因为此时对话框的框架已经绘制了
如果想一点不闪,重载一个OnNcPaint()函数,这是在对话框绘制前响应的消息ON_WM_NCPAINT()
具体如下
void CClientDlg::OnNcPaint()
{
static int i = 1;
if(i > 0)
{
i --;
ShowWindow(SW_HIDE);
}
else
{
CDialog::OnNcPaint();
}
}
根本不隐藏啊,更不用说闪烁
加了你的代码也不行
if(Create(CDlg::IDD,pParent))
{
ShowWindow(SW_HIDE);
}
lg *dlg;然后在InitInstance()中将原来的: 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
}
以及return FALSE;全部删除掉,改为: dlg=new CGetTimeDlg;
m_pMainWnd = dlg;
return dlg->Create(IDD_GETTIME_DIALOG);
最后别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框
变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退
出了,要用DestroyWindow()。 另外将对话框的属性设置为不可见(取消框中more styles 下的visible)
由于在上面的代码中没有将对话框设为可见,所以运行时就实现了隐藏,而且在Window
s任务栏上也没有显示。
lg *dlg;然后在InitInstance()中将原来的: 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
}
以及return FALSE;全部删除掉,改为: dlg=new CGetTimeDlg;
m_pMainWnd = dlg;
return dlg->Create(IDD_GETTIME_DIALOG);
最后别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框
变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退
出了,要用DestroyWindow()。 另外将对话框的属性设置为不可见(取消框中more styles 下的visible)
由于在上面的代码中没有将对话框设为可见,所以运行时就实现了隐藏,而且在Window
s任务栏上也没有显示。