How to enumerate all views of the document

17 03 2010

 

 

A document object can have many views. How to enumerate and communicate with each view individually from document.

 

 

CDocument class has the following members GetFirstViewPosition and GetNextView to enumerate all views associated with the document. Then call view’s OnUpdate function to communicate with them.

 

 

void EnumerateViews()
{
   //get the position of the first view in the list
   //of views associated with the document.
   POSITION pos = GetFirstViewPosition();

   //terate through all of the document's views.
   while (pos != NULL)
   {
      CView* pView = GetNextView(pos);

      //update view
      pView->OnUpdate(pSender, lHint, pHint);
   }
}

 

 

CDocument’s UpdateAllViews using same logic to update all views associated with the document.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: