创建一般的EDIT时正常: hWnd = CreateWindow ("edit",
                        "",
                        WS_VISABLE,
                        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,   
                        CW_USEDEFAULT,
                        NULL,
                        NULL,
                        NULL,
                        NULL);
但在创建RichEdit时出错(找不到窗口类型):
hWnd = CreateWindow ("RichEdit",
                        "",
                        WS_BORDER|ES_MULTILINE,
                        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        NULL,
                        NULL,
                        NULL,
                        NULL);
或者HWND hWnd = CreateWindow (RICHEDIT_CLASS,
                        "",
                        WS_BORDER|ES_MULTILINE,
                        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
                        CW_USEDEFAULT,
                        NULL,
                        NULL,                        
                        NULL,
                        NULL);
都提示相同错误,修改第三个参数仍无法实现。请高手指点。如何才能创建一个RichEdit?

解决方案 »

  1.   

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q261171
    To create the Richedit control you must call the LoadLibrary function on the appropriate Richedit dynamic-link library (DLL) somewhere prior to attempting to create the control. Doing this allows the control to register its class name. For example, to use a Richedit version 2.0 or version 3.0 control in a dialog box, you must call LoadLibrary("riched20.dll") prior to attempting to load and initialize the dialog box resource.When the Resource Editor is used to create a Richedit control, by default it creates version 1.0 of the control with the class name "RichEdit". You can edit the resource file in the text editor and change the class of this control to RichEdit20A and RichEdit20W to request the latest ANSI or Unicode version of the control.
      

  2.   

    直接调用LoadLibrary("riched20.dll")出错(系统找不到指定文件)。
    char* SystemPath=NULL;
    使用GetSystemDirectory(SystemPath,sizeof(SystemPath));无法获得路径,SystemPath仍为NULL为什么?通过查找在系统中找到riched20.dll的路径为C:\WINDOWS\system32于是采用下面方法调用LoadLibrary,但仍出错(系统找不到指定文件):
    SystemPath="C:\\WINDOWS\\system32\\riched20.dll";
    LoadLibrary(SystemPath);或者用
    LoadLibraryEx(SystemPath, NULL, 
                                    LOAD_WITH_ALTERED_SEARCH_PATH);  
    高手请您一定要帮忙指点啊!!!
      

  3.   

    RichEditCtrl需要特殊的支持,在App的InitInstance中加入 AfxInitRichEdit()就行了