可能是RichEdit控件坏了,看看能不能用其他编译器创建RichEdit。顺便问一句,你的NT有Service Pack吗?是什么版本的。

解决方案 »

  1.   

    但是我在一个新线程里面可以创建CRichEditCtrl啊,只是在主线程里面不可以.
      

  2.   

    拷贝控件的动态连结库(dll或ocx),然后注册这个控件;运行:regsvr32 路径\控件的文件名
      

  3.   

    Note: If you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program’s InitInstance member function.
      

  4.   

    我发现原因了,因为我调用了这句
    HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    因为我需要用到com
    把这句注释掉就好了.那么,RichEditCtrl需要什么样的套间模型呢?我需要COM,不可能不要这句啊.
      

  5.   

    原因我已经找到了,如上所述,有没有com高手知道RichEditCtrl需要什么样的套间啊??对于COM我知之甚少,还请各位指教了.
      

  6.   

    try to call AfxInitRichEdit() in InitInstance member function.
      

  7.   

    我不是在一个Dialog上面用RichEditCtrl,所以不用调用这个函数,问题的产生原因已经找到了,因为线程模型不对.我现在想知道的是
    HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    在这个情况下如何创建CRichEditCtrl.
      

  8.   

    HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    我在MFC程序里面需要这个初始化我的线程模型.但是,这样在NT下我就没有办法Create一个CRichEditCtrl了,Create返回False,Getlasterr返回0,原因就是因为线程模型变了,如果我注释掉HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    就可以正常创建.但是在Win2k里面就没有这个问题.
    现在向大家请教,如何在CoInitializeEx(NULL, COINIT_MULTITHREADED);的情况下创建CRichEditCtrl,谢谢
    再次声明,问题产生的原因不是调用AfxInitRichEdit()的问题,是线程模型与COM的问题
      

  9.   

    先创建CRichEditCtrl然后再调用CoInitializeEx()初始化
      

  10.   

    但是那样的话CoInitializeEx会失败,返回线程套间模型已经确定,不能更改
      

  11.   

    如果我后调用CoInitializeEx,那么这个函数报错,原因是"设定线程模型以后不能更改"
      

  12.   

    在NT下如果要用RichEdit必须调用AfxInitRichEdit()
      

  13.   

    是com的问题,不是AfxInitRichEdit()的问题,这一点已经确定了。
      

  14.   

    The CRichEditCtrl class provides the functionality of the rich edit control. This Windows Common control (and therefore the CRichEditCtrl class) is available only to programs running under Windows 95 and Windows NT versions 3.51 and later.
      

  15.   

    版本没有问题,因为只要我注释掉初始化COM线程的那行代码,程序就可以运行良好了