Click to See Complete Forum and Search --> : Rich Edit Problem


mrRee
October 28th, 2004, 02:14 AM
The problem is: when i call the dialog box by click on a button, the dialog box that contain rich edit control didn't appear. I had try to initialize the common control in WinMain, at WM_INITDIALOG, before the DialogBox(...); but they all failed.

This how i initialize the common control:

INITCOMMONCONTROLSEX initCmnCtrls;
initCmnCtrls.dwSize = sizeof(initCmnCtrls);
initCmnCtrls.dwICC = 0x00004000;
InitCommonControlsEx(&initCmnCtrls);

HMODULE hModule = LoadLibrary("D:\\WINNT\\system32\\RichEd20.dll");
if( hModule == NULL )
MessageBox(NULL, "This page requires RichEd20.dll", "Error", MB_OK | MB_ICONERROR );

for InitCmnCtrls.dwICC=0x000040000; i also tried with
InitCmnCtrls.dwICC=ICC_WIN95_CLASSES ; but it also didn't work..

p/s:there is no compile or linking error..I had include comctl32.lib, comctrl.h and richedit.h to my program..

Ejaz
October 28th, 2004, 02:58 AM
Adding Controls to a Dialog Causes the Dialog to No Longer Function (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcresed/html/vctbsaddingcontrolstoadialogcausesthedialogtonolongerfunction.asp)
Also, are you sure that the path is correct? Try it as
HMODULE hRE = LoadLibrary("riched20.dll");
and don't forget to free the library.

mrRee
October 28th, 2004, 03:35 AM
Thanx for the info.. but i think i had done the fixing stuff as the article suggest..

The path to the richedit20.dll is correct as i had search it and confirm it. I also had try to write for just:
HMODULE hModule=LoadLibrary("riched20.dll");

I free the library before EndDialog(); , before DestroyWindow(); and before PostQuitMessage(0); but nothing happens..

Ejaz
October 28th, 2004, 03:41 AM
can you zip the sample code and upload it?

Ejaz
October 28th, 2004, 04:43 AM
Ok, here's the fixed version, try it.

mrRee
October 28th, 2004, 04:56 AM
So it's work.. the trick is change to LoadLibrary=("riched32.dll") and do it without the function call..is that correct?

Anyway thanks a lot...it's a very useful lesson for me.. :)

Ejaz
October 28th, 2004, 05:02 AM
The only significient change is from LoadLibrary=("riched20.dll") to LoadLibrary=("riched32.dll"). I was just fiddling with your code and sent the same version ;)

m466e
October 13th, 2005, 04:38 PM
I would say the real problem is that the resource editor by default creates old 1.0 rich edit controls.
To use the enhanced 2.0-3.0 you will have to manually edit the resource file and change the rich edit control class from "RICHEDIT" to "RICHEDIT20A".
Then there won't be a problem loading RichEd20.dll