Pass the Hint After Modifying the Document

The next task is to pass the hint to the document’s UpdateAllViews member function. You must pass a hint each time a stroke is completed.

To pass the hint after modifying the document

The OnLButtonUp member function is called when a stroke is finished, so you call UpdateAllViews from there. In this function, the view gets the hint information that it will send to the document. It does this by calling the FinishStroke member function for m_pStrokeCur; FinishStroke computes the bounding rectangle for the current stroke. Then the view calls UpdateAllViews, passing two arguments: the this pointer, which identifies this view as the one that performed the modification to the document, and m_pStrokeCur, whose bounding rectangle is the hint. (The function sends a pointer to the entire CStroke object rather than just the bounding rectangle because the hint must be a CObject pointer, and CRect isn’t derived from CObject.) The view doesn’t need to send any more hint information, so it passes nothing (0) in the LPARAM parameter.

The UpdateAllViews function iterates through the list of views attached to the document; for each view (except the one that performed the modification), the function calls its OnUpdate function and passes the hint as a parameter.