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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.