Fucked MFC RichEdit In Visual c++2010!

来源:互联网 发布:淘宝卖家遭遇诈骗 编辑:程序博客网 时间:2024/06/08 19:28

不知为何,个人感觉微软的东西越来越不好用了,今天用Visual 2010 开始写一个MFC程序,结果几乎是什么事情也没干,就花费掉了一个晚上去解决一个令人生烦、内心已经燃烧起了队MS产品的怒火发火……

是这样的,编写了一个MFC程序,才拖了几个控件到界面,然后就运行程序,结果发现编译、生成均没有报任何错,但是,运行是就出问题了,具体是,ctrl+F5运行的话,程序界面没有出来,什么反应也没有;如果F5调试运行的话,同样运行失败,提示信息如下:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
“TempCtrl.exe”: 已加载“F:\TempCtrl_0\Debug\TempCtrl.exe”,已加载符号。
“TempCtrl.exe”: 已加载“C:\Windows\System32\ntdll.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\kernel32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\KernelBase.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\user32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\gdi32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\lpk.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\usp10.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\msvcrt.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\msimg32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\comdlg32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\shlwapi.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd\comctl32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\shell32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\winspool.drv”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\advapi32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\sechost.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\rpcrt4.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\ole32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\oleaut32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\oledlg.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\GdiPlus.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\oleacc.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\imm32.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\msctf.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\winmm.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 6.0 for Windows Workstations MP4\adialhk.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 6.0 for Windows Workstations MP4\kloehk.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\uxtheme.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\dwmapi.dll”,Cannot find or open the PDB file
“TempCtrl.exe”: 已加载“C:\Windows\System32\cryptbase.dll”,Cannot find or open the PDB file
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {251} normal block at 0x022C7FF8, 192 bytes long.
 Data: <                > 02 00 00 00 00 00 00 00 FF FF FF FF 00 00 00 00 
{250} normal block at 0x022C7D50, 100 bytes long.
 Data: <                > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.
线程 'Win32 线程' (0x594) 已退出,返回值为 0 (0x0)。
线程 'Win32 线程' (0x564) 已退出,返回值为 0 (0x0)。
程序“[4920] TempCtrl.exe: 本机”已退出,返回值为 0 (0x0)。
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



感觉莫名奇妙,我的程序什么事情也没做(除了画界面,几乎就没遍码),怎么可能内存泄露,而且编译,生成都没提示错误!这就是visual studio垃圾的地方!

经过一晚上的折腾,后来知道错误在了,我的界面中用到了RichEdit2,使用RichEdit控件时,必须手工在初始化函数中加入对其的初始化函数:AfxInitRichEdit()或AfxInitRichEdit2();否则也会出现我上面说的同样的错误,而我当时把这个AfxInitRichEdit2()函数放在了界面窗口的初始化函数<CTempCtrlDlg::OnInitDialog()>中了,而不是放在整个程序的初始化函数<CTempCtrlApp::InitInstance()>中。结果就导致这样的悲剧了尴尬!!!

不知微软是怎么想的,既然用RichEdit2必须要初始化,为何不由MS MFC自动完成?还用用户自己去添加<这一问题,网络已牛人回答是:MFC向导不对你在创建项目之后增加的内容负责。程序员需要为自己增加的内容添加完整的支持,例如在使用richedit之前调用MFC的richedit初始化函数AfxInitRichEdit>
更要命的是,既然你都要求用RichEdit2必须要初始化,为何用户没有初始化,编译器检测不出? 这个检查应该不难吧?

关于这个问题,可能是我自己对MFC理解的很浅,但我个人总体感觉微软的东西越来越不好用!


原创粉丝点击