Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to paint MFC SDI application main window from a dialog

60 views
Skip to first unread message

Angus

unread,
Jun 17, 2009, 7:31:24 AM6/17/09
to
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

unread,
Jun 17, 2009, 8:53:04 AM6/17/09
to
>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

unread,
Jun 17, 2009, 1:37:19 PM6/17/09
to
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

"Angus" <angus...@gmail.com> wrote in message
news:94fbbdeb-c55f-4158...@f19g2000yqo.googlegroups.com...

0 new messages