改变程序启动顺序带来的问题

ChangYong ChangYong 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我先建一个MFC的程序,这个程序是基于Single document的,能后在程序中添加一个对话框类,能后执行程序,此时程序运行时弹出视图的框架,现在我想让程序一启动先弹出一个对话框,当我按确另时在弹出视图的框架,按取消是推出程序,我是如下修改代码的,但有问题要解决:按取消时屏幕中总会闪一下那个视图的框架,怎么才能不让它闪一下而是直接推出程序?
===============我修改的代码,除此一外程序没有另何代码=================================
BOOL CTestApp::InitInstance()
{
// The one and only window has been initialized, so show and update it.
CTestdlg dlg;//Ctestdlg是我添加的对话框类
//m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
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

// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));

LoadStdProfileSettings(); // Load standard INI file options (including MRU)

// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTestDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTestView));
AddDocTemplate(pDocTemplate);

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
}
else if (nResponse == IDCANCEL)
{
return FALSE;//TRUE;
}

return TRUE;
}
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
ChangYong
网络编程 18,356 成员 64,161 内容