Creating the View
Scribble: MDI Drawing Application, Lesson 4
Tip If you prefer working from a printed tutorial, see in MSDN Library Help for details about printing a lesson, a set of topics, or a single topic.
This lesson and the previous lesson, Creating the Document, cover Step 1 of Scribble.
Suggested Reading
Note You can find a finished example of this lesson's code in the Scribble Step1 sample source code directory.
In this lesson, you will add a view class that provides a “view on the document.” You will add code to Scribble’s view files, ScribbleView.h and ScribbleView.cpp. You will also add two more member functions to class CStroke
in ScribbleDoc.cpp. Begin with the files from your Scribble root project directory.
At this point, your files should consist of the starter files you created with AppWizard in Creating a New Application with AppWizard and modified in Creating the Document. As you read this lesson, add all lines of code as instructed in the procedures. At the end of this lesson, your files should closely resemble the Step1 source code files, and your Scribble program should compile and run.
Scribble’s view class displays the strokes of a drawing and accepts user input from the mouse. Among the things you will develop in this lesson are:
Code to display Scribble’s strokes — in class
CScribbleView
.Code to handle Windows messages as the user draws with the mouse — also in class
CScribbleView
.
While you’re adding code, you will continue to use ClassView and WizardBar to jump directly to your code.
You will also use WizardBar to:
Map Windows messages to message-handler member functions in your classes.
Map the commands generated by user-interface objects such as menu items, toolbar buttons, and accelerator keys to message-handler functions.