Programmatically opening a new document and write a string in a CRichEditView.

J

John

I wrote a MDI application with a CRichEditView. When the user clicks on a
button the program displays a dialog box and after the user closes the
dialog box the program has to open a new document and then write a text
string in it. I wrote the following code to do that.

void CFormatPlannerView::OnPlaylistGenerate()
{
CGenerateDlg dlg;
if (dlg.DoModal() == IDOK)
{
CFormatPlannerApp* pApp= (CFormatPlannerApp*)AfxGetApp();
pApp->pDocTemplate->OpenDocumentFile(NULL);
GetRichEditCtrl().ReplaceSel("Test playlist\n");
}
}

I want the function to open a new document and then write the text string in
the new document but what happens is that the function opens a new document
(document2) and then writes the text string in document1 instead of
document2. Any suggestions on how to fix this?

Thanks in advance,

John.
 
V

Victor Bazarov

John said:
I wrote a MDI application with a CRichEditView. When the user [...]
Any suggestions on how to fix this?

Nope. Please post MFC questions to an MFC newsgroup. I know
of two: comp.os.ms-windows.programmer.tools.mfc and
microsoft.public.vc.mfc. I bet you even are allowed to cross-
post in those. Here, OTOH, MFC is OT.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,351
Latest member
LolaD32479

Latest Threads

Top