每道理啊,完全一样的代码(用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;
...全文
65 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Jans 2001-05-07
众位大哥不要笑话
我确实对此问题不太清楚原因
我还是耐着性子找到了
不过还是很迷惑,我想这也许是VC的Bug吧这么倒霉让我遇上了
这一句有问题(原文Copy):
EnableShellOpen();
改正后:
EnableShellOpen();
好像就是把几个空格改成Tab,就莫名其妙的好了
他妈的 VC
  • 打赏
  • 举报
回复
fulaoxiao 2001-05-07
绝对同意smint(smint) 
  • 打赏
  • 举报
回复
smint 2001-05-07
把不同的地方注出来阿.还要人家自己找阿?累
  • 打赏
  • 举报
回复
发帖
VC/MFC
加入

1.6w+

社区成员

VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
申请成为版主
帖子事件
创建了帖子
2001-05-07 07:03
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……