每道理啊,完全一样的代码(用Windiff比较过的)怎么编译后就不一样了,真是奇怪
Jans 2001-05-07 07:03:00 这是那个App的InitInstance()函数
这两段代码很短的看上去完全一样,为什么编译后不一样(多次测试发现),差别就在双击打开文件时,一个能打开,一个则出错,难道是VC编译器自己的问题?浪费了我很多时间高手请看看:
正确的代码:
#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("Noise Demo Platform"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
{
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
return TRUE;
}
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
}
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_NOISEDTYPE,
RUNTIME_CLASS(CNoiseDemoPlatformDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CNoiseDemoPlatformView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// pMainFrame->InitializeMenu(pDocTemplate,
// IDR_NOISEDTYPE, IDR_MAINFRAME, IDR_MAINFRAME);
// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
m_nCmdShow|=SW_SHOWMAXIMIZED;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
ShowTipAtStartup();
return TRUE;
有问题的:
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Noise Demo Platform"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
{
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
return TRUE;
}
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
}
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_NOISEDTYPE,
RUNTIME_CLASS(CNoiseDemoPlatformDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CNoiseDemoPlatformView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// pMainFrame->InitializeMenu(pDocTemplate,
// IDR_NOISEDTYPE, IDR_MAINFRAME, IDR_MAINFRAME);
// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
m_nCmdShow|=SW_SHOWMAXIMIZED;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
ShowTipAtStartup();
return TRUE;