In the View-Document model, only the View class processes mouse clicks. Which means that the program needs to jump through a couple of routines to detect and react to the user's mouse.
After adding the OnLButtonDown(UINT flags, CPoint point) handler to the View class, similar functions need to be added to the Document and the Board. The View calls the Document and the Document calls the Board.
Step 11: In the Document's mouse handler, void onClick(const CPoint& point), there are only three statements that need to be taken.
Assert that there is an instance of the Board class. (CBoard::getInstance() != NULL)
Call the Board's mouse handler.
Update view. Here the programmer will use UpdateAllViews(NULL). As only one View is associated with the Document, it does not matter if one goes through the effort to find the pointer this single View or just uses NULL for all (meaning one) Views. The other bit is that with only one parameter used, no hint value is passed and the OnUpdate routine will just Invalidate() the drawing area.
Note: I used a const reference for the click point as I did not see any need to manipulate the mouse.
Step 12: There are more things to process in the Board class's mouse handler, void onClick(const CPoint& point).
Check pre-conditions. (Is there a valid instance? Is places valid?)
Is the game over? (I tested a boolean variable to avoid calling a routine.) If finished, congratulate the user again and return.
Find the CRect object in places that contains the CPoint object point. It is highly recommended not to use the loop variable as the record holder for this. Currently C++ standards mean that this variable is likely to be out-of-scope outside of the loop. Most compilers will enforce this, although there are reportedly some that will keep the loop variable visible outside of the loop.
Ignoring out-of-bounds index values (less than 0 and greater than or equal to the Board's size variable squared), process the relevant state value and test for completion. If complete, congratulate the user and set the boolean finished variable for future reference.
Process post-conditions. (Is the Board instance still valid?)