[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Transfer data from 1 view to another

I'm trying to load data into a buffer from 1 view and send to to a document, then to another view for editing.  WHat's the appropriate way to do so?

This is a split window application with 2 views.  Basically view 1 reads data from a file to a buffer.  I know how to send it to the document, but how can the document inform view 2 that there is new data to display?  View 2 is a richedit control, and I want to set the text with something like:


Thanks,  Veronica
1 Solution
Use the built in Doc View communication in MFC. Something like this...

// In View1
// (Assuming you have already sent the
// data to the document)


// This causes OnUpdate to be called in
// all views...

// In View2
void CView2::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  if (pSender && pSender->IsKindOf(RUNTIME_CLASS(CView1)))
    // View1 is signaling new data has arrived.
    // Use GetDocument() to get a pointer
    // to the doc, you can then access the data
    // directly.
veronicasAuthor Commented:
Excellent!  You saved this newbie a lot of work!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now