Where to initialize a rich edit control on another dialog?
up vote
0
down vote
favorite
I have an MFC dialog based application that has 2 Dialogs: Main Dialog CMyDlg
and Second dialog CMyDlg2
.
On the main Dialog I add a Button "Go dialog 2". So I added a handler for the button so that when clicked it pops up the second dialog. Everything works fine But on the second Dialog I have added a Rich Edit Control from toolbox. I Added for it a variable. I also added a class for the second dialog.
Now If I run the Application I get the dialog one and if I pressed "Go to dialog 2" I got what I want. But I need at some point to change the font of the rich edit control but my program crashes.
So I overrided OnInitDialog
and inside it do some changes to the control but program crashes. After debugging I found that the handle of rich edit is null?!
So how and where can I change the color or do some initializations to the control?
(I called AfxInitRichEdit2()
in OnInitInstance()
)
BOOL CMyDlg2::OnInitDialog() {
m_richEdit.SetWindowText("Hello there!"); // program crashes because the handle m_richEdit is null.
return TRUE;
}
And this is the handler of button that creates the Dialog2 and that contains the rich edit control:
void CMyDlg::OnBnClickedButton1(){
CMyDlg2 theDlg;
theDlg.DoModal();
// TODO: Add your control notification handler code here
}
- If I create the rich edit control programmatically then everything works fine because I create it at
OnInitDialog
and then it works fine but I need the one that is I added using the wizard toolbox.
*** The thing is that if I write:
m_richEdit.SetWindowText(""); // program crashes but if I wirte:
GetDlgItem(IDC_RICHEDIT221).SetWindowText(""); it works fine?
c++ mfc
|
show 8 more comments
up vote
0
down vote
favorite
I have an MFC dialog based application that has 2 Dialogs: Main Dialog CMyDlg
and Second dialog CMyDlg2
.
On the main Dialog I add a Button "Go dialog 2". So I added a handler for the button so that when clicked it pops up the second dialog. Everything works fine But on the second Dialog I have added a Rich Edit Control from toolbox. I Added for it a variable. I also added a class for the second dialog.
Now If I run the Application I get the dialog one and if I pressed "Go to dialog 2" I got what I want. But I need at some point to change the font of the rich edit control but my program crashes.
So I overrided OnInitDialog
and inside it do some changes to the control but program crashes. After debugging I found that the handle of rich edit is null?!
So how and where can I change the color or do some initializations to the control?
(I called AfxInitRichEdit2()
in OnInitInstance()
)
BOOL CMyDlg2::OnInitDialog() {
m_richEdit.SetWindowText("Hello there!"); // program crashes because the handle m_richEdit is null.
return TRUE;
}
And this is the handler of button that creates the Dialog2 and that contains the rich edit control:
void CMyDlg::OnBnClickedButton1(){
CMyDlg2 theDlg;
theDlg.DoModal();
// TODO: Add your control notification handler code here
}
- If I create the rich edit control programmatically then everything works fine because I create it at
OnInitDialog
and then it works fine but I need the one that is I added using the wizard toolbox.
*** The thing is that if I write:
m_richEdit.SetWindowText(""); // program crashes but if I wirte:
GetDlgItem(IDC_RICHEDIT221).SetWindowText(""); it works fine?
c++ mfc
2
m_richEdit
won't beNULL
, but it's window handle will beNULL
because it's not created as a window yet. You have to call the default method first. Change to:BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
2
To be precise, the richedit window has already been created inCMyDlg2::OnInitDialog()
, but it won't be associated with them_richEdit
variable, unless the base class'sOnInitDialog()
method is called.
– zett42
Nov 11 at 22:51
1
Basically like Barmak wrote, but__super
is Microsoft-specific, I would writeCDialog::OnInitDialog()
instead, which is standard C++.
– zett42
Nov 11 at 23:04
1
It looks like you are calling the base class method nowCMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.
– Barmak Shemirani
Nov 11 at 23:33
1
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47
|
show 8 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an MFC dialog based application that has 2 Dialogs: Main Dialog CMyDlg
and Second dialog CMyDlg2
.
On the main Dialog I add a Button "Go dialog 2". So I added a handler for the button so that when clicked it pops up the second dialog. Everything works fine But on the second Dialog I have added a Rich Edit Control from toolbox. I Added for it a variable. I also added a class for the second dialog.
Now If I run the Application I get the dialog one and if I pressed "Go to dialog 2" I got what I want. But I need at some point to change the font of the rich edit control but my program crashes.
So I overrided OnInitDialog
and inside it do some changes to the control but program crashes. After debugging I found that the handle of rich edit is null?!
So how and where can I change the color or do some initializations to the control?
(I called AfxInitRichEdit2()
in OnInitInstance()
)
BOOL CMyDlg2::OnInitDialog() {
m_richEdit.SetWindowText("Hello there!"); // program crashes because the handle m_richEdit is null.
return TRUE;
}
And this is the handler of button that creates the Dialog2 and that contains the rich edit control:
void CMyDlg::OnBnClickedButton1(){
CMyDlg2 theDlg;
theDlg.DoModal();
// TODO: Add your control notification handler code here
}
- If I create the rich edit control programmatically then everything works fine because I create it at
OnInitDialog
and then it works fine but I need the one that is I added using the wizard toolbox.
*** The thing is that if I write:
m_richEdit.SetWindowText(""); // program crashes but if I wirte:
GetDlgItem(IDC_RICHEDIT221).SetWindowText(""); it works fine?
c++ mfc
I have an MFC dialog based application that has 2 Dialogs: Main Dialog CMyDlg
and Second dialog CMyDlg2
.
On the main Dialog I add a Button "Go dialog 2". So I added a handler for the button so that when clicked it pops up the second dialog. Everything works fine But on the second Dialog I have added a Rich Edit Control from toolbox. I Added for it a variable. I also added a class for the second dialog.
Now If I run the Application I get the dialog one and if I pressed "Go to dialog 2" I got what I want. But I need at some point to change the font of the rich edit control but my program crashes.
So I overrided OnInitDialog
and inside it do some changes to the control but program crashes. After debugging I found that the handle of rich edit is null?!
So how and where can I change the color or do some initializations to the control?
(I called AfxInitRichEdit2()
in OnInitInstance()
)
BOOL CMyDlg2::OnInitDialog() {
m_richEdit.SetWindowText("Hello there!"); // program crashes because the handle m_richEdit is null.
return TRUE;
}
And this is the handler of button that creates the Dialog2 and that contains the rich edit control:
void CMyDlg::OnBnClickedButton1(){
CMyDlg2 theDlg;
theDlg.DoModal();
// TODO: Add your control notification handler code here
}
- If I create the rich edit control programmatically then everything works fine because I create it at
OnInitDialog
and then it works fine but I need the one that is I added using the wizard toolbox.
*** The thing is that if I write:
m_richEdit.SetWindowText(""); // program crashes but if I wirte:
GetDlgItem(IDC_RICHEDIT221).SetWindowText(""); it works fine?
c++ mfc
c++ mfc
edited Nov 12 at 0:02
asked Nov 11 at 21:45
Maestro
7410
7410
2
m_richEdit
won't beNULL
, but it's window handle will beNULL
because it's not created as a window yet. You have to call the default method first. Change to:BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
2
To be precise, the richedit window has already been created inCMyDlg2::OnInitDialog()
, but it won't be associated with them_richEdit
variable, unless the base class'sOnInitDialog()
method is called.
– zett42
Nov 11 at 22:51
1
Basically like Barmak wrote, but__super
is Microsoft-specific, I would writeCDialog::OnInitDialog()
instead, which is standard C++.
– zett42
Nov 11 at 23:04
1
It looks like you are calling the base class method nowCMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.
– Barmak Shemirani
Nov 11 at 23:33
1
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47
|
show 8 more comments
2
m_richEdit
won't beNULL
, but it's window handle will beNULL
because it's not created as a window yet. You have to call the default method first. Change to:BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
2
To be precise, the richedit window has already been created inCMyDlg2::OnInitDialog()
, but it won't be associated with them_richEdit
variable, unless the base class'sOnInitDialog()
method is called.
– zett42
Nov 11 at 22:51
1
Basically like Barmak wrote, but__super
is Microsoft-specific, I would writeCDialog::OnInitDialog()
instead, which is standard C++.
– zett42
Nov 11 at 23:04
1
It looks like you are calling the base class method nowCMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.
– Barmak Shemirani
Nov 11 at 23:33
1
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47
2
2
m_richEdit
won't be NULL
, but it's window handle will be NULL
because it's not created as a window yet. You have to call the default method first. Change to: BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
m_richEdit
won't be NULL
, but it's window handle will be NULL
because it's not created as a window yet. You have to call the default method first. Change to: BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
2
2
To be precise, the richedit window has already been created in
CMyDlg2::OnInitDialog()
, but it won't be associated with the m_richEdit
variable, unless the base class's OnInitDialog()
method is called.– zett42
Nov 11 at 22:51
To be precise, the richedit window has already been created in
CMyDlg2::OnInitDialog()
, but it won't be associated with the m_richEdit
variable, unless the base class's OnInitDialog()
method is called.– zett42
Nov 11 at 22:51
1
1
Basically like Barmak wrote, but
__super
is Microsoft-specific, I would write CDialog::OnInitDialog()
instead, which is standard C++.– zett42
Nov 11 at 23:04
Basically like Barmak wrote, but
__super
is Microsoft-specific, I would write CDialog::OnInitDialog()
instead, which is standard C++.– zett42
Nov 11 at 23:04
1
1
It looks like you are calling the base class method now
CMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.– Barmak Shemirani
Nov 11 at 23:33
It looks like you are calling the base class method now
CMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.– Barmak Shemirani
Nov 11 at 23:33
1
1
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47
|
show 8 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You probably have the following code inserted by wizard:
void DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT22, m_richEdit);
}
This tells the dialog to associate m_richEdit
with the dialog control IDC_RICHEDIT22
. But this association is not performed until the base class method CDialog::OnInitDialog();
is called.
BOOL CMyDlg2::OnInitDialog()
{
//this line should work:
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
//this line won't work:
//m_richEdit.SetWindowText("Hello there!"); <- richedit's handle is NULL
//this line will subclass m_richEdit
//plus run other initialization
CDialog::OnInitDialog();
//m_richEdit is ready
m_richEdit.SetWindowText("Hello there!");
return TRUE;
}
It's recommended to put CDialog::OnInitDialog()
int the first line, to make sure the initialization is done.
GetDlgItem
works because the control IDC_RICHEDIT22
exists in the dialog template and you have a valid dialog handle. You are basically making a simple call based on WinAPI's GetDlgItem
:
HWND hedit = ::GetDlgItem(m_hWnd, IDC_RICHEDIT22);
::SetWindowText(hedit, "Hello world");
There is no additional initialization needed.
But m_richEdit
is just a C++ object, declared as CRichEditCtrl m_richEdit;
The constructor for this C++ class doesn't do much besides setting m_hWnd
to NULL
.
Once it's associated with a valid window handle, we can begin using its windows methods such as CRichEdit::SetWindowText
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain whyGetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?
– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You probably have the following code inserted by wizard:
void DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT22, m_richEdit);
}
This tells the dialog to associate m_richEdit
with the dialog control IDC_RICHEDIT22
. But this association is not performed until the base class method CDialog::OnInitDialog();
is called.
BOOL CMyDlg2::OnInitDialog()
{
//this line should work:
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
//this line won't work:
//m_richEdit.SetWindowText("Hello there!"); <- richedit's handle is NULL
//this line will subclass m_richEdit
//plus run other initialization
CDialog::OnInitDialog();
//m_richEdit is ready
m_richEdit.SetWindowText("Hello there!");
return TRUE;
}
It's recommended to put CDialog::OnInitDialog()
int the first line, to make sure the initialization is done.
GetDlgItem
works because the control IDC_RICHEDIT22
exists in the dialog template and you have a valid dialog handle. You are basically making a simple call based on WinAPI's GetDlgItem
:
HWND hedit = ::GetDlgItem(m_hWnd, IDC_RICHEDIT22);
::SetWindowText(hedit, "Hello world");
There is no additional initialization needed.
But m_richEdit
is just a C++ object, declared as CRichEditCtrl m_richEdit;
The constructor for this C++ class doesn't do much besides setting m_hWnd
to NULL
.
Once it's associated with a valid window handle, we can begin using its windows methods such as CRichEdit::SetWindowText
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain whyGetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?
– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
add a comment |
up vote
2
down vote
accepted
You probably have the following code inserted by wizard:
void DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT22, m_richEdit);
}
This tells the dialog to associate m_richEdit
with the dialog control IDC_RICHEDIT22
. But this association is not performed until the base class method CDialog::OnInitDialog();
is called.
BOOL CMyDlg2::OnInitDialog()
{
//this line should work:
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
//this line won't work:
//m_richEdit.SetWindowText("Hello there!"); <- richedit's handle is NULL
//this line will subclass m_richEdit
//plus run other initialization
CDialog::OnInitDialog();
//m_richEdit is ready
m_richEdit.SetWindowText("Hello there!");
return TRUE;
}
It's recommended to put CDialog::OnInitDialog()
int the first line, to make sure the initialization is done.
GetDlgItem
works because the control IDC_RICHEDIT22
exists in the dialog template and you have a valid dialog handle. You are basically making a simple call based on WinAPI's GetDlgItem
:
HWND hedit = ::GetDlgItem(m_hWnd, IDC_RICHEDIT22);
::SetWindowText(hedit, "Hello world");
There is no additional initialization needed.
But m_richEdit
is just a C++ object, declared as CRichEditCtrl m_richEdit;
The constructor for this C++ class doesn't do much besides setting m_hWnd
to NULL
.
Once it's associated with a valid window handle, we can begin using its windows methods such as CRichEdit::SetWindowText
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain whyGetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?
– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You probably have the following code inserted by wizard:
void DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT22, m_richEdit);
}
This tells the dialog to associate m_richEdit
with the dialog control IDC_RICHEDIT22
. But this association is not performed until the base class method CDialog::OnInitDialog();
is called.
BOOL CMyDlg2::OnInitDialog()
{
//this line should work:
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
//this line won't work:
//m_richEdit.SetWindowText("Hello there!"); <- richedit's handle is NULL
//this line will subclass m_richEdit
//plus run other initialization
CDialog::OnInitDialog();
//m_richEdit is ready
m_richEdit.SetWindowText("Hello there!");
return TRUE;
}
It's recommended to put CDialog::OnInitDialog()
int the first line, to make sure the initialization is done.
GetDlgItem
works because the control IDC_RICHEDIT22
exists in the dialog template and you have a valid dialog handle. You are basically making a simple call based on WinAPI's GetDlgItem
:
HWND hedit = ::GetDlgItem(m_hWnd, IDC_RICHEDIT22);
::SetWindowText(hedit, "Hello world");
There is no additional initialization needed.
But m_richEdit
is just a C++ object, declared as CRichEditCtrl m_richEdit;
The constructor for this C++ class doesn't do much besides setting m_hWnd
to NULL
.
Once it's associated with a valid window handle, we can begin using its windows methods such as CRichEdit::SetWindowText
You probably have the following code inserted by wizard:
void DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT22, m_richEdit);
}
This tells the dialog to associate m_richEdit
with the dialog control IDC_RICHEDIT22
. But this association is not performed until the base class method CDialog::OnInitDialog();
is called.
BOOL CMyDlg2::OnInitDialog()
{
//this line should work:
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
//this line won't work:
//m_richEdit.SetWindowText("Hello there!"); <- richedit's handle is NULL
//this line will subclass m_richEdit
//plus run other initialization
CDialog::OnInitDialog();
//m_richEdit is ready
m_richEdit.SetWindowText("Hello there!");
return TRUE;
}
It's recommended to put CDialog::OnInitDialog()
int the first line, to make sure the initialization is done.
GetDlgItem
works because the control IDC_RICHEDIT22
exists in the dialog template and you have a valid dialog handle. You are basically making a simple call based on WinAPI's GetDlgItem
:
HWND hedit = ::GetDlgItem(m_hWnd, IDC_RICHEDIT22);
::SetWindowText(hedit, "Hello world");
There is no additional initialization needed.
But m_richEdit
is just a C++ object, declared as CRichEditCtrl m_richEdit;
The constructor for this C++ class doesn't do much besides setting m_hWnd
to NULL
.
Once it's associated with a valid window handle, we can begin using its windows methods such as CRichEdit::SetWindowText
edited Nov 12 at 3:26
answered Nov 12 at 0:02
Barmak Shemirani
20.5k42044
20.5k42044
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain whyGetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?
– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
add a comment |
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain whyGetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?
– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Yes I have that code inserted by the wizard.
– Maestro
Nov 12 at 0:03
Would you mind to explain why
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?– Maestro
Nov 12 at 0:06
Would you mind to explain why
GetDlgItem(IDC_RICHEDIT22)->SetWindowText("Hello");
works?– Maestro
Nov 12 at 0:06
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
I added more clarification in Edit.
– Barmak Shemirani
Nov 12 at 0:21
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
Understood now! thank you for your help and efforts and time.
– Maestro
Nov 12 at 0:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253556%2fwhere-to-initialize-a-rich-edit-control-on-another-dialog%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
m_richEdit
won't beNULL
, but it's window handle will beNULL
because it's not created as a window yet. You have to call the default method first. Change to:BOOL CMyDlg2::OnInitDialog(){__super::OnInitDialog();m_richEdit.SetWindowText("Hello there!");return TRUE;}
– Barmak Shemirani
Nov 11 at 22:06
2
To be precise, the richedit window has already been created in
CMyDlg2::OnInitDialog()
, but it won't be associated with them_richEdit
variable, unless the base class'sOnInitDialog()
method is called.– zett42
Nov 11 at 22:51
1
Basically like Barmak wrote, but
__super
is Microsoft-specific, I would writeCDialog::OnInitDialog()
instead, which is standard C++.– zett42
Nov 11 at 23:04
1
It looks like you are calling the base class method now
CMyDlg2::OnInitDialog(){CDialog::OnInitDialog(); ...}
that should work.– Barmak Shemirani
Nov 11 at 23:33
1
Sure, you are welcome.
– Barmak Shemirani
Nov 11 at 23:47