6.4. Updating the views

The UpdateAllViews( CView* pSender, int lHint, CObject* pHint) method generates calls to the CPopView::OnUpdate( CView* pSender, int lHint, CObject* pHint) method for each open view, passing on the same arguments.

A minimal version of the OnUpdate method could look like this.

void CPopView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{ 
    Invalidate(); /* Enqueue a message asking Windows to call OnDraw 
        for this view. */ 
} 

Invalidate produces a call to OnDraw, which is where the critters get drawn to the active window.

But what about the three arguments to UpdateAllViews and OnUpdate ? It’s possible for a view to initiate a call to UpdateAllViews with a line like this: GetDocument()->UpdateAllViews. This trick ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.