Connecting Messages to Code

In this topic, instead of directly adding lines of code to a file in the text editor, you’ll first use WizardBar to make connections between Windows messages and their handler functions. ClassWizard adds an entry to the message map in ScribbleView.cpp for class CScribbleView and writes a default member function definition to the same file for the handler function. Then, as described in the next topic, Adding the Message-Handler Functions, you use WizardBar to jump directly to the starter member function, and you fill in the function’s code.

To connect the messages to Scribble’s code

  1. Using WizardBar, from the Class combo box, select CScribbleView. Click the arrow on the action button on the right end of WizardBar. Click Add Windows Message Handler.

  2. In the New Windows Message Handler dialog box, select WM_LBUTTONDOWN from the New Windows Messages to Handle list. Click Add Handler.

    You won’t fill in the handler just yet.

  3. Repeat steps 2 and 3 for the additional mouse messages: WM_LBUTTONUP and WM_MOUSEMOVE.

  4. Click OK.

After you click Add Handler, ClassWizard does the following tasks to associate each of the three messages with its handler and to greatly simplify your work: