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
You won’t fill in the handler just yet.
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:
CScribbleView
class declaration in file ScribbleView.h: afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
CScribbleView
’s message map in file ScribbleView.cpp:ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
OnLButtonDown
:void CScribbleView::OnLButtonDown( UINT nFlags, CPoint point )
{
// TODO: Add your message handler code here
// and/or call default
CView::OnLButtonDown( nFlags, point );
}
Notice that ClassWizard embeds a comment reminding you what to do and adds a call to the CView::OnLButtonDown
.