Interpreting User Input Through a View
Other member functions of the view handle and interpret all user input. You will usually define message-handler member functions in your view class to process:
Windows messages generated by mouse and keyboard actions.
Commands from menus, toolbar buttons, and accelerator keys.
These message-handler member functions interpret the following actions as data input, selection, or editing, including moving data to and from the Clipboard:
Mouse movements and clicks, drags, and double-clicks
Which Windows messages your view handles depends on your application's needs.
Message Handling and Mapping Topics explains how to assign menu items and other user-interface objects to commands and how to bind the commands to handler functions. Message Handling and Mapping Topics also explains how MFC routes commands and sends standard Windows messages to the objects that contain handlers for them.
For example, your application might need to implement direct mouse drawing in the view. The Scribble sample shows how to handle the WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP messages respectively to begin, continue, and end the drawing of a line segment. On the other hand, you might sometimes need to interpret a mouse click in your view as a selection. Your view's OnLButtonDown handler function would determine whether the user was drawing or selecting. If selecting, the handler would determine whether the click was within the bounds of some object in the view and, if so, alter the display to show the object as selected.
Your view might also handle certain menu commands, such as those from the Edit menu to cut, copy, paste, or delete selected data using the Clipboard. Such a handler would call some of the Clipboard-related member functions of class CWnd to transfer a selected data item to or from the Clipboard.