在程序中添加 Richedit2.0控件后,程序启动不了,原因是:使用Richedit 控件,必须初始化,否则不能运行。
处理方法:
1、MFC
在应用程序类的InitInstance函数体内添加语句:
::AfxInitRichEdit(): //调用RichEdit的初始化函数
2、WTL
在CMyApp.cpp 中加入(红色部分):
方法a:==========================================================
HMODULE hMod;
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::OleInitialize(NULL);
hMod = LoadLibrary(_T("riched20.dll")); ATLASSERT(SUCCEEDED(hRes));
// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
::DefWindowProc(NULL, 0, 0, );
AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
FreeLibrary(hMod);
::OleUninitialize();
return nRet;
}
方法b:==========================================================
在WTL或win32编程中,也可以在 _tWinMain主函数里只加一句即可 LoadLibrary(_T("riched20.dll"));
评论(0)