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

ChangYong 2004-12-29 08:18:50
我先建一个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;
}
...全文
75 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChangYong 2005-01-02
  • 打赏
  • 举报
回复
Toneedways(天涯浪子)、laiyiling(陌生人.VC_FANS):好象还是有闪一下,我要求做到就象只有一个对话框一样,按取消按钮程序很自能的突出,请问VC能做到吗?
Kudeet 2004-12-31
  • 打赏
  • 举报
回复
CTestdlg dlg;
if(dlg.DoModal()!=IDOK)
return FALSE;
sharkhuang 2004-12-31
  • 打赏
  • 举报
回复
cancel就直接退出!exit还会闪嘛?
needways 2004-12-31
  • 打赏
  • 举报
回复
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 == IDCANCEL)
return FALSE;

...

return TRUE;
}

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧