Solved

How do you display RichEdit in a dialog?

Posted on 1998-08-02
12
265 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?
0
Comment
Question by:fredmastro
  • 6
  • 5
12 Comments
 
LVL 2

Author Comment

by:fredmastro
ID: 1320148
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.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1320149
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.
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320150
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.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 2

Author Comment

by:fredmastro
ID: 1320151
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
0
 
LVL 8

Expert Comment

by:trestan
ID: 1320152
Use
HINSTANCE m_instRE = ::LoadLibrary(_T("RICHED32.DLL"));
I do not think you need to reject an answer to get following information.
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320153
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.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1320154
You can define HINSTANCE m_instRE as a member variable of your CWinApp class and call LoadLibrary in the InitInstance, FreeLibrary in the ExitInstance.
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320155
How do I do that Chensu?
0
 
LVL 23

Accepted Solution

by:
chensu earned 70 total points
ID: 1320156
You can use the ClassWizard to add a private member variable HINSTANCE m_instRE in your CWinApp class and add the virtual member function ExitInstance. It should look like

class CMyWinApp : public CWinApp
{
//...
// Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CPnApp)
        public:
        virtual BOOL InitInstance();
        virtual int ExitInstance();
       //}}AFX_VIRTUAL

private:
    HINSTANCE m_instRE;
//...
};

BOOL CMyWinApp::InitInstance()
{
//...
    m_instRE = ::LoadLibrary(_T("RICHED32.DLL"));
//...
}

int CMyWinApp::ExitInstance()
{
//...
    if (m_instRE != NULL)
        ::FreeLibrary(m_instRE);

    return CWinApp::ExitInstance();
//...
}

0
 
LVL 23

Expert Comment

by:chensu
ID: 1320157
By the way, you do not need to reject the answer to ask more questions if there is nothing wrong with the answer.
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320158
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)
0
 
LVL 23

Expert Comment

by:chensu
ID: 1320159
There should be only one class derived from CWinApp. The CMyWinApp I mentioned refers to that only one class.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 61
cat dog challenge 18 124
Host to IP 7 78
wait notify demo infinite loop 3 110
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question