Chapter 16. Creating the Document and Improving the View

In this chapter, you'll look into the facilities offered by MFC for managing collections of data items; these are similar to the STL containers discussed in Chapter 10. You'll use the MFC collection classes to complete the class definition and implementation for the curve element that was left open in MFC Sketcher in the last chapter. You'll extend the MFC Sketcher to make the document view more flexible, introducing several new techniques in the process. You'll also extend the MFC and CLR versions of Sketcher to store elements in an object that encapsulates a complete sketch.

In this chapter, you'll learn about:

  • MFC collections and what you can do with them

  • How to use an MFC List collection and an STL/CLR vector container to store point data for a curve

  • How to use an MFC List collection and an STL/CLR list container to store sketch data

  • How to implement drawing a sketch in the MFC and CLR versions of Sketcher

  • How to implement scrolling in a view in MFC Sketcher

  • How to create a context menu at the cursor

  • How to highlight the element nearest the cursor to provide feedback to the user for moving and deleting elements

  • How to program the mouse to move and delete elements

The MFC Collection Classes

By the nature of Windows programming, you'll frequently need to handle collections of data items where you have no advance knowledge of how many items you will need to manage, or even what particular type they are going to be. This is clearly illustrated ...

Get Ivor Horton's Beginning Visual C++®2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.