25.3. Persistent display

It takes some work to make a Windows program have a persistent display that stays in place even if the window is resized or covered and then uncovered.

The OnDraw method

The standard practice is to have our Windows programs do all their writing to the screen within one single function, the CView::OnDraw method. When does your CView get an OnDraw message? Here are four important ways that this can happen.

  • When the CView is first created, whether automatically at startup, by a File | New call or by a Window | New call. First there’s a call to the constructor, then a call to OnCreate, and then a call to OnDraw.

  • Whenever your CView gets resized, whether by dragging a corner using a command like Window | Tile, or by clicking ...

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.