Tutorials
|
|
Menu of tutorialsTutorial 1: The Simplest Window
The previous example fails to repaint the window. Repainting the window
is required whenever the window is resized, restored from minimized, or when
part of the window is revealed after being covered by another window. The Windows API handles repainting automatically. When part of a window
needs repainting, windows sends a WM_PAINT message to the application.
Typically you would respond to this message with the code to redraw the
entire client area of the window. You don't need to concern yourself with
which parts of the client area need to be redrawn, as windows handles this
part for you automatically. Win32++ already contains the code to handle the WM_PAINT message in
CWnd::WndProc. All we need to do is write the OnDraw function. For our
application here, we can store the various points in a vector, and have the
OnDraw function draw the lines again. The function to store the points
looks like this. Our OnDraw function looks like this. The source code for this tutorial is located within the Tutorial folder of the software available from SourceForge at http://sourceforge.net/projects/win32-framework. |