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;
}
解决方案 »
- 请教分配内存的区别:new、malloc、GlobalAlloc、LocalAlloc、HeapAlloc、VirtualAlloc
- MFC 一个新建的类无法在另一个类中定义对象
- mfc消息高手来看看,可以说很难的一题
- 如何实现文件/文件夹的剪切 复制 粘贴功能
- htmltoimage,谁能给个思路?
- vs.net中怎么找不到ClassWizard控制面板
- if(!totalmap.Lookup(caller,map_charge)) map_charge="";这句怎么解释?
- 关于游戏场景中右键菜单的问题!
- 关于CArray和CTypedPtrList的模板类问题
- MFC单文档请问如何设置窗口的大小?
- 如何设置状态栏indicator的宽度,我指的是所有indicator的总宽度
- Tab控件中的FormView页面数据更新问题
ShowWindow写到 ClocktimeDlg.cpp中去
不然对话框还是会出来.
DoModal();下面的代码,在对话框运行时哪有机会运行,在对话框结束时有机会运行,可是整个程序结束了!
在ClocktimeDlg的OnInitDialog函数里,生成一个时间很短的定时器,比如10毫秒,然后在OnTimer函数里面响应这个定时器,定写上如下程序:
PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
ShowWindow(SW_HIDE);直接改为
int nResponse = dlg.ShowWindow(SW_HIDE);