Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 1: Introduction to Visual C++


otherwise, after selecting it in the New dialog box, click the arrow of the Open As combo
box

Practical Learning: Creating a C++ File



  1. On the main menu, click File -> New...

  2. Make sure the Files tab is selected. Click C++ Source File

  3. In the Name edit box, type Main and press Enter

  4. In the empty file, type the following:


#include <iostream>
#include <string>
using namespace std;

int main()
{
cout << "Welcome to College Park - Auto Parts\n";

return 0;
}


  1. To save everything, on the Standard toolbar, click the Save All button


1.3.3 Adding Existing Files to a Project.......................................................


If a file had already been created and exists on a separate folder, drive, directory or
project, you can import and add it to your application. When you decide to adding an
existing file to a project, because Visual allows you a great level of flexibility on the
types of files you can add, it is your responsibility to check that the file is “valid”,
especially if the file was neither created using MSVC nor compiled in Visual C++.

If you copy a file from somewhere and paste it in the folder that contains your project, the
file is still not considered as part of the project. You must explicitly add it. Before adding
an existing file to your project:
?? On the main menu, you can click File -> Add Existing Item...

?? On the main menu, you can also click Project -> Add Existing Item...
?? In the Solution Explorer, you can right-click the name of the project, position
your mouse on Add and click Add Existing Item...
Any of these actions would open the Add Existing Item dialog box. This requires you to
locate the item and select it. Once the item is ready, to add it to the project, click the
Open button. If you want to open it first, click the arrow of the Open button and specify
how you want to open the file.

Practical Learning: Adding a File to a Project



  1. On the main menu, click Project -> Add To Project -> Files...

  2. Locate the folder that contains the exercises that accompany this book and display it
    in the Look In combo box.

Free download pdf