BOOL CClocktimeApp::InitInstance()
{
if(++g_lAppInstance>1)
{
AfxMessageBox("程序已经运行!");
return FALSE;
}


AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable, you should remove from the following
//  the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CClocktimeDlg dlg;
m_pMainWnd = &dlg;    
int nResponse = dlg.DoModal();
ShowWindow(GetMainWnd()->GetSafeHwnd(),SW_HIDE); //使窗口最小化
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;
}

解决方案 »

  1.   

    m_pMainWnd ->ShowWindow(SW_HIDE);
      

  2.   

    这样写ShowWindow根本没有在对话框显示时执行
    ShowWindow写到 ClocktimeDlg.cpp中去
      

  3.   

    正如楼上所说,但是在ClocktimeDlg.cpp中什么地方加呢?多谢
      

  4.   

    还要在ON_SIZE消息的响应函数中添加 m_pMainWnd ->ShowWindow(SW_HIDE);
    不然对话框还是会出来.
      

  5.   

    SW_HIDE似乎也不是最小化,而是隐藏窗口,最小化是SW_MINIMIZE
      

  6.   


    DoModal();下面的代码,在对话框运行时哪有机会运行,在对话框结束时有机会运行,可是整个程序结束了!
    在ClocktimeDlg的OnInitDialog函数里,生成一个时间很短的定时器,比如10毫秒,然后在OnTimer函数里面响应这个定时器,定写上如下程序:
    PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
      

  7.   

    OnInitDialog里加就可以
    ShowWindow(SW_HIDE);直接改为
    int nResponse = dlg.ShowWindow(SW_HIDE);
      

  8.   

    m_pMainWnd ->ShowWindow(SW_HIDE);