Share via


Binding Visual Objects to Code Using WizardBar

Scribble: MDI Drawing Application, Lesson 6

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.

Suggested Reading in the Visual C++ Programmer’s Guide

Like all applications written for Windows, Scribble is message driven. A keystroke, mouse click, or other event causes messages to be sent to some part of the application that can respond to the event. In Adding the Message-Handler Functions, in Lesson 4, for example, you saw that Scribble implements mouse drawing by detecting and responding to messages generated by mouse clicks and drags.

This lesson discusses a category of messages called “commands,” which are messages to your application from menu items, toolbar buttons, and accelerator keys.

The expanded version of Scribble developed in this lesson adds two menu items:

  • One generates commands to toggle the line thickness for drawing.

  • One clears all strokes from the current document.

The command that toggles line thickness is also duplicated by a button on Scribble’s toolbar.

You created the resources for Scribble’s new menu items and its new toolbar button in Edit Scribble’s Menus and Edit Scribble’s Toolbar in Lesson 5. Now you can use WizardBar to assign a user-interface object, such as a menu item, to a command and map the command to a function that handles it.

In this lesson, you will:

At the end of this lesson, your files should closely resemble the Step2 source code files, and your Scribble program should compile and run.

Note   You can find a finished example of this lesson's code in the Scribble Step2 sample source code directory.