Downloading Horstmann's Graphics Libraries and Creating a Visual C++ project that Uses Them

for Visual C++ .NET


Before you can do graphics, you need to do some code library installation.

Download the following zip file: .
(NOTE: This is a local copy; the original can be found at http://www.horstmann.com/ccc/ccc3e.zip)

Unzip these files in a reasonable spot on your hard drive.

Create a new project. Under "Application Settings", select Windows application, Empty project. DO NOT CREATE A "CONSOLE" APPLICATION.

Add the cccfiles directory to the include path. To do this, perform the following steps:

  1. Select your project in the Solution Explorer. This should be the first item immediately under the item named "Solution".
  2. Choose "Property Pages" from the "View" menu.
  3. In the window that appears, Select "C/C++ -> General" in the list box on the left.
  4. Click on the empty box to the right of the box that says "Additional Include Directories". No visual cues there, eh?
  5. A button with ellipsis ("...") will magically appear - click on this button. (we did NOT design this user interface)

  6. In the window that appears, click on button with the folder at the top.
  7. Another button with ellipsis will appear - click on this button.
    BEFORE AFTER
  8. Navigate to the place where you unzipped the Horstmann code library.
  9. Select the "cccfiles" directory.
  10. Click the button that says "Open".
  11. Hit OK as many times as needed to return the main window.

Your aerobic activities should have you near a "jogger's high" by now. Think you're done? Don't you wish! Add ccc_win.h, ccc_msw.cpp and ccc_shap.cpp to the project (also ccc_msw.h and ccc_shap.h), by clicking on Project -> Add Existing Item..., and selecting these files.

Now, create a new source file and add it to the project.

#include "ccc_win.h"

int ccc_win_main()
{
  Point p(1, 3);
  cwin << p << Circle(p, 2.5);

  return 0;
}

Compile and run your program. If you're lucky, all goes well, you should produce a graphics window with the following output: