Discussion:
How to paint MFC SDI application main window from a dialog
(too old to reply)
Angus
2009-06-17 11:31:24 UTC
Permalink
I have created an MFC SDI application and I have a dialog class - eg
MyDialog. I am new to MFC programming and want to be able to write
text to the main view window. how do I do that?
David Lowndes
2009-06-17 12:53:04 UTC
Permalink
Post by Angus
I have created an MFC SDI application and I have a dialog class - eg
MyDialog. I am new to MFC programming and want to be able to write
text to the main view window. how do I do that?
Angus,

One way would be to have a public method in your document class to
enable your dialog to call back passing the string. If you pass a
pointer to your document in the constructor of your dialog (and save
it in a member variable) the dialog will then have access to the
function. The document function should use UpdateAllViews to get any
views updated with the new text.

Dave
Tom Serface
2009-06-17 17:37:19 UTC
Permalink
Do you want to write the text while the dialog is displaying? If so I would
just send a message to the parent window (assuming it's the view) and have
the message handler in the main window update the window. If you want to
wait until the dialog is closed you could easily add the text as a CString
member variable in your dialog and fish it out from the main window that
called the dialog:

MyDialog dlg;

if(dlg.DoModal() == IDOK) {
m_csMainViewText = dlg.csText;
Invalidate(); // Assumes this will cause m_csMainViewText to be drawn
in the view
}

Tom
Post by Angus
I have created an MFC SDI application and I have a dialog class - eg
MyDialog. I am new to MFC programming and want to be able to write
text to the main view window. how do I do that?
Loading...