-
New at programming
Here is my code.
void CTestDlg::OnOK()
{
CString szEdit;
m_editTest.GetWindowText(szEdit);
AfxMessageBox(szEdit);
// TODO: Add extra validation here
CDialog::OnOK();
}
Can someone please tell me how to make this output go to a new window or to the window I already have open instead of a AfxMessageBox.
Thanks
-
Re: New at programming
It's depends a bit on what you are going to do! You must remember that when You click on OK you also end this dialog, so putting the text in the current dialog isn't practical since you would have to have a VERY slow computer to read it ;-)
To mimic the AfxMessageBox you can:
1. Create an dialog in the dialog editor that consist of one Text object (Remeber to change the ID from IDC_STATIC to something else that you think is logical, like IDC_TESTTXT. You also need an OK button, you could remove the cancel...
2. Activate the ClassWizard (Ctrl-W) and create a new class for this dialog.
2. goto member variables (still in classwizard) and create an CString variable(m_txt) for the IDC_TESTTXT.
3. Now go back to the OnOK function and add this dialog:
CTestTxtDia dlg; // or what ever you called the class
4. copy the text from szEdit to the new dialog
dlg.m_txt = szEdit;
5. Start the new dialog
dlg.DoModal();
This will do exactly like your code.
// Anders
[ccode]
void CTestDlg::OnOK()
{
CString szEdit;
CTestTxtDia dlg;
m_editTest.GetWindowText(szEdit);
// here comes the new dialog
dlg.m_txt = szEdit;
dlg.DoModal();
// End this dialog
CDialog::OkOK();
}
Thought I could organise freedom
how Scandinavian of me