myokoy03
asked on
RichEdit programmed text insert
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
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
ASKER
Adjusted points to 30
ASKER
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?
Should I be using StreamIn( ) instead?
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
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
ASKER
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.
class CMDIView : public CRichEditView
{
..
..
..
2. There is no dialog as far as I can see.
3. I will give it a try.
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
btw the preferred method for setting text in the richedit control is ReplaceSel().
HTH
NooGie
ASKER
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("He llo, world", TRUE);
I get a message
error C2065: 'GetRichEditCtrl' : undeclared identifier
Then if I enter
const CRichEditCtrl m_HndRECtrl;
m_HndRECtrl =
CRichEditView::GetRichEdit Ctrl();
m_HndRECtrl.ReplaceSel("He llo, world", TRUE);
I get a message
error C2352: 'CRichEditView::GetRichEdi tCtrl' : 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?
If I enter:
const CRichEditCtrl m_HndRECtrl;
m_HndRECtrl = GetRichEditCtrl();
m_HndRECtrl.ReplaceSel("He
I get a message
error C2065: 'GetRichEditCtrl' : undeclared identifier
Then if I enter
const CRichEditCtrl m_HndRECtrl;
m_HndRECtrl =
CRichEditView::GetRichEdit
m_HndRECtrl.ReplaceSel("He
I get a message
error C2352: 'CRichEditView::GetRichEdi
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?
ASKER
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.
ASKER
QUESTION FOUND AN ANSWER!!
This finally worked:
GetRichEditCtrl().ReplaceS el("Hello, world", TRUE);
as a method of the CMDIView class.
This finally worked:
GetRichEditCtrl().ReplaceS
as a method of the CMDIView class.
noogie6.,
Please post an answer for the points.
Ian
Community Support @ Experts Exchange
Please post an answer for the points.
Ian
Community Support @ Experts Exchange
ASKER
noogie6, your answer proves to be correct. Please post another answer so that we can award you the points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, thanks noogie6, I thought we lost you in the sea of information that is the World Wide Web....
Here m_richEdit will be a member variable to the richedit or if that seems confusing try
((CRichEditCtrl *)GetDlgItem(IDC_RICHCTRL)
Here IDC_RICHCTRL is the ID of ur richedit
Cheers