Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RichEdit programmed text insert

Posted on 2000-02-26
13
Medium Priority
?
331 Views
Last Modified: 2013-11-20
I am trying to enhance a program that I got from the AppWizard.  It is a MDI Rich Edit program.

I cannot figure out what goes to the left hand side of a

   SetWindowText( )

method.

I am supposing here that I need a pointer to the class that has the RichEdit funtion in the AppWizard generated program.

The Rich Edit program created by the AppWizard seems so efficiently designed that there isn't an example of a "handle" to a RichEdit control.

Many examples, for instance, has this

  m_richEdit->SetWindowText( )

however, in this case, m_richEdit hasn't been previously declared in the program.

How can I declare and use the left hand side of SetWindowText( ) ?

Thanks
0
Comment
Question by:myokoy03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 1

Expert Comment

by:RAVID
ID: 2562174
Hi,

Here m_richEdit will be a member variable to the richedit or if that seems confusing try
((CRichEditCtrl *)GetDlgItem(IDC_RICHCTRL))->SetWindowText("..");

Here IDC_RICHCTRL is the ID of ur richedit

Cheers



0
 

Author Comment

by:myokoy03
ID: 2563203
Adjusted points to 30
0
 

Author Comment

by:myokoy03
ID: 2563204
I don't have the identifier IDC_RICHCTRL in my .CLW file.  Does that mean that the AppWizard generates examples WITHOUT RichEdit??

Should I be using StreamIn( ) instead?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Expert Comment

by:VinExpert
ID: 2565239
Hi,

Have U created a MDI application with the view derived from the CRichEditView?.... OR U have downloaded it from some where?.

Is Ur main view itself is the richedit or it is there in a dialog?....

specify Ur problem clearly.

Give this a try on some event.

CClientDC dc(this);
dc.TextOut(10,10,"Hi there");

VinExpert
0
 

Author Comment

by:myokoy03
ID: 2566073
1.  This is something that originated from an MDI application generated by the AppWizard.  I just executed the AppWizard, chose MDI and chose RichEdit.  In mdiview.h it says:

class CMDIView : public CRichEditView
{
..
..
..

2.  There is no dialog as far as I can see.

3.  I will give it a try.
0
 

Expert Comment

by:noogie6
ID: 2568154
Your CRichEditView has all the functionality of the RichEdit control. You can call GetRichEditCtrl() to call functions and access members on the richedit control. Events from the control are reflected to the view so you can handle them there.
btw the preferred method for setting text in the richedit control is ReplaceSel().

HTH
NooGie
0
 

Author Comment

by:myokoy03
ID: 2568793
We seem to be getting close on a resolution to this problem.

If I enter:

  const CRichEditCtrl m_HndRECtrl;
  m_HndRECtrl = GetRichEditCtrl();
  m_HndRECtrl.ReplaceSel("Hello, world", TRUE);

I get a message

error C2065: 'GetRichEditCtrl' : undeclared identifier

Then if I enter

  const CRichEditCtrl m_HndRECtrl;
  m_HndRECtrl =
    CRichEditView::GetRichEditCtrl();
  m_HndRECtrl.ReplaceSel("Hello, world", TRUE);

I get a message

error C2352: 'CRichEditView::GetRichEditCtrl' : illegal call of non-static member function

But then if I check the MS help for this, it seems that it may be a possible compiler error problem and they present workarounds that may require ?redefining the RichEdit declarations?
0
 

Author Comment

by:myokoy03
ID: 2568829
That is a pretty good answer as far as I can tell, and it might have been good enough to any experienced MFC user, and I am so new to MFC programming that I need a very very explicit answer.  I have posted my attempts in a comment here.
0
 

Author Comment

by:myokoy03
ID: 2570989
QUESTION FOUND AN ANSWER!!

This finally worked:

GetRichEditCtrl().ReplaceSel("Hello, world", TRUE);

as a method of the CMDIView class.
0
 
LVL 5

Expert Comment

by:ianB
ID: 2574023
noogie6.,

Please post an answer for the points.

Ian
Community Support @ Experts Exchange
0
 

Author Comment

by:myokoy03
ID: 2585954
noogie6, your answer proves to be correct.  Please post another answer so that we can award you the points.
0
 

Accepted Solution

by:
noogie6 earned 120 total points
ID: 2696780
My points please, didn't check for a while :)
0
 

Author Comment

by:myokoy03
ID: 2697087
Okay, thanks noogie6, I thought we lost you in the sea of information that is the World Wide Web....
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

660 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