Home > Store

Sams Teach Yourself Visual C++ 6 in 21 Days

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Visual C++ 6 in 21 Days


  • Sorry, this book is no longer in print.
Not for Sale



Question 1: After starting the Docs, it said it was "preparing the INDEX for the first time." After a while, the program stopped responding. Why is this so and how can I rectify this problem?

Solution 1: You did not allow enough time to pass. The process will look as if it has stopped several times throughout. Please allow about 15 to 20 minutes.

Question 2: Day 2 - When I try to add member variables, none of the controls are listed in the ClassWizard so I can't assign any member variables to any controls.

Solution 2: You can go back to the application box and Right click on the controls and go to Properties. Change the Setting to match the text. Ex. Edit Box to IDC_MSG.

Question 3: I accidentally closed the Controls Palette. How do I get it back?

Solution 3: After the project is open on the screen, do the following:

-click: Tools
-click: Customize
-click: Toolbars tab
-put a checkmark in the box for Controls
-click: Close

The Controls Palette will appear on the screen.

Question 4: I am getting errors on Day 10 - Day10Doc.h - about CLine and GetLine.

Solution 4: The problem is solved by simply including the #include "Line.h" at the Day10Doc.h file as well as the c++ source code.

Question 5: After Installing the CD and trying to run the program, I get an error message that states "MSDEV caused an invalid page fault in DEVBLD.PKG"

Solution 5: You should be able to solve the problem by downloading the Visual C++ Service update from MS. Update 2 may not get it to work but Update 3 should.

Question 6: Day 3 - Page 63, I followed the steps in the book and when I try to rebuild, I am getting the following error message
link:fatal error LLNK1104: can not open file "NAFXCWD.LIB"

Solution 6: If, in VC++, you open Tools | Options (from the pulldown menus), select the Directories tab, and then select Library files in the right combo box, the reader should have the "...\VC98\MFC\LIB" and "...\VC98\LIB" included in the directory paths. From the looks of the file name, I'd say that the one pointing to the MFC\LIB directory is missing, or pointing to the wrong directory.

Question 7: On page 117, listing 6.3, the popup menu does not popup anywhere near the pointer. Also TrackPopupMenu() the first param. doesn't seem to function properly.

Solution 7: 1) The context menu does not appear in the right location with lines 13 - 16. Remove these lines, and it appears properly.
2) Line 18, "m_lMenu - GetMenu();" should be "m_lMenu = GetMenu();".
3) Line 23, "m_pPoint.x, m_pPoint.y" should be "point.x, point.y" because of 1) above in this paragraph.

Question 8: I keep coming up with an error message.
Reads: configuration:hello-win 32Debug Compiling resources
Link: fatal error link 1168: cannot open debug/hello.exe for writing error executing link.exe H hello.exe - 1error(s), 0 warning(s)

Solution 8: The error that you are running into is because Visual C++ cannot create the .EXE executable in the final step of compiling. There are two likely causes for this. The first possible cause of this error is that you are out of disk space on your computer. The second possible cause of this is that there is already a .EXE file with the same name on your computer, and it is marked as "read-only." Did you copy the source code from a CD? Normally, any files you copy from a CD are automatically marked as "read-only" and you'll need to unmark these files by hand. You can do this in the Windows Explorer by selecting the file, right clicking the mouse (over the file), and opening the file properties from the context menu. In the properties for the file, you should see a check box indicating if the file is "read-only". If the
.EXE file is marked as "read-only", then you can uncheck this box and save the updated file properties.

There is actually a third possible cause for this error, and that is if you are trying to compile the project directly from the CD. If you are trying to do this, you need to copy the entire project directory to your hard disk and try to compile it there. If you open the project from the CD, the compiler
will try and create the .EXE file on the CD.

Question 9: Problem compiling listing 8.3 on pages 163-164.

Solution 9: The text on page 163 discusses creating a single event handler function for use with all of the radio buttons. The source code for this function is in listing 8.3. What you need to do is add a function to the clicked event on every radio button, changing the suggested function name to the OnRSelection function name. This will point all of the radio buttons to this one function to call when any of them are selected.


  • Copyright 1998
  • Dimensions: 7-3/8" x 9-1/8"
  • Pages: 800
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-31240-9
  • ISBN-13: 978-0-672-31240-3

Learn Visual C++ through the Teach Yourself series, with sections on: Q&A, Do's and Don'ts, Workshop, Shaded syntax boxes, Type/Output/Analysis icons. Week One starts you with Visual C++. After installing and maneuvering through the components of the software, you'll examine a preliminary program to get the feel for C++ and Visual C++. You'll learn: C++ basics; hierarchies; members, functions, and objects; inheritance; MFC; installing Visual C++, the Visual C++ compiler. In Week Two, you'll look at components of Windows applications and how they are invoked with Visual C++. Topics include: keyboard input; mouse usage; data file handling; lists and serialization; toolbars and status bars; graphics; and projects. Week Three examines the more involved aspects of Visual C++ and Windows applications.



Source code for Days 1 - 21 - 3699 kb days.zip

Source code for Class 1 - 230 kb class1.exe

Source code for Class 2 - 235 kb class2.exe

Source code for Class 3 - 240 kb class3.exe

Inherit Program - 251 kb inherit.exe

Inherit 2 Program - 246 kb inherit2.exe

Overload Program - 313 kb overload.exe

Pointers Program - 276 kb pointers.exe

Reference Program - 511 kb reference.exe

Triangle Program - 380 kb triangle.exe

Triangle 2 Program - 291 kb trianglep.exe

Variable Program - 270 kb variable.exe

Source Code

Source code for Days 1 - 21 - 3699 kb days.zip

Source code for Class 1 - 230 kb class1.exe

Source code for Class 2 - 235 kb class2.exe

Source code for Class 3 - 240 kb class3.exe

Inherit Program - 251 kb inherit.exe

Inherit 2 Program - 246 kb inherit2.exe

Overload Program - 313 kb overload.exe

Pointers Program - 276 kb pointers.exe

Reference Program - 511 kb reference.exe

Triangle Program - 380 kb triangle.exe

Triangle 2 Program - 291 kb trianglep.exe

Variable Program - 270 kb variable.exe

Sample Content

Table of Contents


Day Day 1. The Visual C++ Development Environment—Building Your First Visual C++ Application.

The Visual C++ Development Environment. Starting Your First Project. Designing Your Application Window. Adding Code to Your Application. Finishing Touches. Summary. Q&A. Workshop.

Day Day 2. Using Controls In Your Application.

The Basic Windows Controls. Adding Controls to Your Window. Attaching Variables to Your Controls. Attaching Functionality to the Controls. Summary. Q&A. Workshop.

Day 3. Allowing User Interaction—integrating The Mouse And Keyboard In Your Application.

Understanding Mouse Events. Capturing Keyboard Events. Summary. Q&A. Workshop.

Day 4. Working With Timers.

Understanding Windows Timers. Placing a Clock on Your Application. Adding a Second Timer to Your Application. Summary. Q&A. Workshop.

Day 5. Getting User Feedback—Adding Dialog Boxes To Your Application.

Using Pre-existing (or System) Dialog Windows. Creating Your Own Dialog Windows. Summary. Q&A. Workshop.

Day 6. Creating Menus For Your Application.

Menus. Designing Menus. Creating a Menu. Creating Pop-Up Menus. Creating a Menu with Accelerators. Summary. Q&A. Workshop.

Day 7. Working With Text And Fonts.

Finding and Using Fonts. Using Fonts. Summary. Q&A. Workshop. WEEK 1 IN REVIEW.


Day 8. Adding Flash—Incorporating Graphics, Drawing, And Bitmaps.

Understanding the Graphics Device Interface. Creating a Graphics Application. Summary. Q&A. Workshop.

Day 9. Adding Activex Controls To Your Application.

What Is an ActiveX Control? 9. Adding an ActiveX Control to Your Project. Using an ActiveX Control in Your Application. Summary. Q&A. Workshop.

Day 10. Creating Single Document Interface Applications.

The Document/View Architecture. Creating an SDI Application. Saving and Loading the Drawing. Interacting with the Menu. Summary. Q&A. Workshop.

Day 11. Creating Multiple Document Interface Applications.

What Is an MDI Application? 9. Creating an MDI Drawing Program. Adding a Context Menu. Summary. Q&A. Workshop.

Day 12. Adding Toolbars And Status Bars.

Toolbars, Status Bars, and Menus. Designing a Toolbar. Adding a Combo Box to a Toolbar. Adding a New Status Bar Element. Summary. Q&A. Workshop.

Day 13. Saving And Restoring Work—file Access.

Serialization. Implementing a Serializable Class. Summary. Q&A. Workshop.

Day 14. Retrieving Data From An Odbc Database.

Database Access and ODBC. Creating a Database Application Using ODBC. Summary. Q&A. Workshop. WEEK 2 IN REVIEW.


Day 15. Updating And Adding Database Records Through Ado.

What Is ADO? 9. Building a Database Application Using ADO. Summary. Q&A. Workshop.

Day 16. Creating Your Own Classes And Modules.

Designing Classes. Creating Library Modules. Using Library Modules. Summary. Q&A. Workshop.

Day 17. Sharing Your Functionality With Other Applications—Creating Dlls.

Why Create DLLs? 9. Creating and Using an MFC Extension DLL. Creating and Using a Regular DLL. Summary. Q&A. Workshop.

Day 18. Doing Multiple Tasks At One Time—Multitasking.

What Is Multitasking? 9. Building a Multitasking Application. Summary. Q&A. Workshop.

Day 19. Building Your Own Widgets—Creating Activex Controls.

What Is an ActiveX Control? 9. Creating an ActiveX Control. Summary. Q&A. Workshop.

Day 20. Internet Applications And Network Communications.

How Do Network Communications Work? 9. Building a Networked Application. Summary. Q&A. Workshop.

Day 21. Adding Web Browsing Functionality To Your Applications.

The Internet Explorer ActiveX Model. The CHtmlView Class. Building a Web-Browsing Application. Summary. Q&A. Workshop. WEEK 3 IN REVIEW.


Appendix A. C++ Review.

Creating Your First Application. Pointers. Classes. Inheritance. Summary.

Appendix B. Answers.

Day 1. Day 2. Day 3. Day 4. Day 5. Day 6. Day 7. Day 8. Day 9. Day 10. Day 11. day 12. Day 13. Day 14. Day 15. Day 16. Day 17. Day 18. Day 19. Day 20. Day 21.

Appendix C. Printing And Print Previewing.

Using the Framework's Functionality. Pagination and Orientation. Direct Printing Without the Framework.

Appendix D. Understanding And Exception Handling.

Using Exceptions. MFC Exception Types.

Appendix E. Using The Debugger And Profiler.

Creating Debugging and Browse Information. Tracing and Single Stepping. Additional Debugging Tools.

Appendix F. Using MFC's Helper Classes.

Using the Collection Classes. Using the Coordinate-Handling Classes. Using the Time-Handling Classes. Using the String Manipulation Class.



Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership