以下是我在基于对话框开发的一个程序,现在碰到的问题是我想在程序启动时首先启动登陆对话框,在登陆对话框内如果点击ok则顺利启动程序,如果点击cancel则程序启动结束,但我在以下代码中点击登陆对话框ok按扭后程序没能启动起来!!希望大家帮我看看这个问题是怎么回事!!谢谢BOOL CMyApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
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 CEnterDlg dlg1;
int nResponse = dlg1.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CVideoCaptureDlg dlg;
m_pMainWnd = &dlg;
}
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;
}int CMyApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
return CWinApp::ExitInstance();
}
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
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 CEnterDlg dlg1;
int nResponse = dlg1.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CVideoCaptureDlg dlg;
m_pMainWnd = &dlg;
}
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;
}int CMyApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
return CWinApp::ExitInstance();
}
解决方案 »
- 如何将两条相交粗直线转化为两个区域的相交?
- vs2005+6410SDK安装后编译总是出现库文件错误
- 如何画圆形按钮,请高手解答!
- 求开发模块
- 关于生成一个基于单文档的dll,然后再如何调用的问题(急)
- sms数据包中的编码问题~
- 请问:使用的完成端口的客户/服务器之间时如何的传递信息呢?
- @@@@@@@@@@ 经验问题: 比较难---怎么将多个回调函数 定义成一个回调函数数组? @@@
- 怎样在程序中为编辑框增加client edge属性
- SNMP:如何确保TRAP消息发送到指定的管理控制台主机
- 各位:现在我有个棘手的问题,想问问大家在线等待。。。也就是FOXMAIL的 CLSID是多少,我无论怎么在注册表里找不到
- 请问WIN系统关机函数
int nResponse = dlg1.DoModal(); if (nResponse == IDCANCEL)
{
return FALSE;
} CVideoCaptureDlg 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
}
int nResponse = dlg1.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CVideoCaptureDlg dlg;
m_pMainWnd = &dlg;
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
return FALSE
}
我按照楼上老兄的方法试了,点击取消按扭可以中断程序启动,但点击ok却为啥不能正常启动程序呢,谢谢