We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How do you display RichEdit in a dialog?

fredmastro
fredmastro asked
on
Medium Priority
322 Views
Last Modified: 2013-11-19
When ever I ad a RichEdit control to my dialog box, the dialog box will not come up on the screen when I run it.  But if I remove the RichEdit control, then the dialog box comes up just fine.   I want to use a RichEdit box instead of a Edit box to show some info.  How do I get my Dialog box to show up with it?
Comment
Watch Question

Author

Commented:
ALSO, how do I add a CString Variable to the RichEdit box.  when I go in Class Wizard, under Variables, I can't add a variable to it.

Commented:
You need to load the RichEdit DLL (RICHED32.DLL for version 1.0 or RICHED20.DLL for version 2.0) before creating the dialog box and free it after destroying the dialog box.

m_instRE = ::LoadLibrary(_T("RICHED32.DLL"));

if (m_instRE != NULL)
    ::FreeLibrary(m_instRE);

You should associate the RichEdit control to CRichEditCtrl instead of CString.

Author

Commented:
Chensu, Where do I get m_instRE  from?  I can't add a variable to the RichEdit Control, the Class Wizrd won't let me.

Author

Commented:
This is the error message I get when I paste your code in.

'm_instRE' : undeclared identifier

D:\DEV STUDIO\MY PROJECTS\MCA AUTORUN\MCA Autorun\NumbersDlg.cpp(52) : error C2440: '=' : cannot convert from 'struct INSTANCE__ *' to 'int'
                                                                 This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Commented:
Use
HINSTANCE m_instRE = ::LoadLibrary(_T("RICHED32.DLL"));
I do not think you need to reject an answer to get following information.

Author

Commented:
Well I didn't get no errors trestan. Thanks.  But my dialog window still won't show up.  When I click on the assoicated button, nothing happens.

Commented:
You can define HINSTANCE m_instRE as a member variable of your CWinApp class and call LoadLibrary in the InitInstance, FreeLibrary in the ExitInstance.

Author

Commented:
How do I do that Chensu?
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
By the way, you do not need to reject the answer to ask more questions if there is nothing wrong with the answer.

Author

Commented:
Sorry about that, with the answer thing.
I appreciate your help.  But where do I define the HINSTANCE? The dialog with the RichEdit box is off of the main dialog box.  I looked in ClassWizrd but not sure where to add what you mentioned.  Under CMainApp? Or Under CRichEditApp?  (The RichEditApp being loaded off the the MainApp)

Commented:
There should be only one class derived from CWinApp. The CMyWinApp I mentioned refers to that only one class.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.