Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

12
Using Using Microsoft Visual Microsoft Visual Studio Studio 2005 2005 Original by Suma Rao Original by Suma Rao Revised by John G. McMahon Revised by John G. McMahon ( 9/6/2008 ) ( 9/6/2008 )

Transcript of Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

Page 1: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

Using Using Microsoft Visual StudioMicrosoft Visual Studio

2005 2005

Original by Suma RaoOriginal by Suma RaoRevised by John G. McMahonRevised by John G. McMahon

( 9/6/2008 )( 9/6/2008 )

Page 2: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 2

TopicsTopics

► Before Starting Visual Studio 2005 (VS2005)Before Starting Visual Studio 2005 (VS2005)► Starting Visual Studio 2005 (VS2005)Starting Visual Studio 2005 (VS2005)► Creating VS2005 ProjectCreating VS2005 Project► Creating VS2005 Source FileCreating VS2005 Source File► Saving VS2005 Source FileSaving VS2005 Source File► Building Source Files to ExecutableBuilding Source Files to Executable► Running ProgramRunning Program► Closing VS2005 Project/SolutionClosing VS2005 Project/Solution► Opening an Existing VS2005 Project/SolutionOpening an Existing VS2005 Project/Solution

Page 3: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 3

Before Starting VS2005Before Starting VS2005

For a new project, use Windows For a new project, use Windows Explorer or some other method to Explorer or some other method to create a new folder on a hard drive create a new folder on a hard drive where your entire solution/project will where your entire solution/project will be stored. Consider using a short be stored. Consider using a short descriptive name which will descriptive name which will characterize the project. This path characterize the project. This path will be used in a later step.will be used in a later step.

Page 4: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 4

Starting VS2005Starting VS20051.1. Click the Click the StartStart button from the Windows taskbar button from the Windows taskbar

and select and select All Programs All Programs Microsoft Visual Microsoft Visual Studio 2005 Studio 2005 (Application) (Application) Microsoft Visual Microsoft Visual Studio 2005 Studio 2005 (Executable). (Executable). [1][1]

2.2. A A Choose Default Environment SettingsChoose Default Environment Settings window appears. window appears. [2] [2] (only first time after VS2005 (only first time after VS2005 installation)installation)

3.3. Choose Choose Visual C++ Development SettingsVisual C++ Development Settings [3] [3] and click and click Start Visual StudioStart Visual Studio button.button. (only first (only first time after VS2005 installation)time after VS2005 installation)

4.4. Visual Studio 2005 starts and a Visual Studio 2005 starts and a Start Page - Start Page - Microsoft Visual StudioMicrosoft Visual Studio window appears. window appears. [4][4]

► SnapShots of Starting VS2005SnapShots of Starting VS2005

Page 5: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 5

Creating VS2005 ProjectCreating VS2005 Project

4.4. From theFrom the Start Page - Microsoft Visual StudioStart Page - Microsoft Visual Studio window window EITHEREITHER click on click on New ProjectNew Project button button [1] [1]

OROR from the from the File File menu, selectmenu, select NewNew Project... Project... [2][2]

5.5. AA New ProjectNew Project dialog box appears. dialog box appears. [3][3]

6.6. FromFrom thethe Project Types: Project Types: section, selectsection, select Visual C+Visual C++, +, thenthen General General.. [3][3]

7.7. From theFrom the Templates:Templates: section, selectsection, select Empty Project Empty Project icon.icon. [3][3] Then select the locationThen select the location for the project for the project created before starting VS2005 by clicking thecreated before starting VS2005 by clicking the Browse…Browse… button at the end of thebutton at the end of the Location:Location: text text box box [3][3], a, a Project LocationProject Location dialog boxdialog box appears. appears. [4][4]

Page 6: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 6

Creating VS2005 Project Creating VS2005 Project (cont’d…)(cont’d…)

5.5. Select the locationSelect the location for the project that was created for the project that was created before starting VS2005 and clickbefore starting VS2005 and click Open Open in thein the Project Project LocationLocation dialog box.dialog box. [4][4] The path selected appears in The path selected appears in the the Location:Location: text box. text box. [5][5]

6.6. Enter a project name in theEnter a project name in the Name:Name: text box text box [5][5] (ex: (ex: Test). This will be the name of the executable file.Test). This will be the name of the executable file.

7.7. Check box labeled: “Create directory for solution”. Check box labeled: “Create directory for solution”. [5][5] Enter a solution name in the Enter a solution name in the Solution Name:Solution Name: text box text box (ex: sln_Test). (ex: sln_Test). [6][6] Click the Click the OKOK button.button.

8.8. The The Solution Explorer Solution Explorer window appears with the window appears with the solution name in the title bar. The solution and project solution name in the title bar. The solution and project structures appear in the structures appear in the Solution Explorer Solution Explorer window. window. [7][7]

► SnapShots of Creating VS2005 ProjectSnapShots of Creating VS2005 Project

Page 7: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 7

Creating VS2005 Source Creating VS2005 Source FileFile

1.1. In the In the Solution Explorer Solution Explorer window, right click window, right click Source FilesSource Files,, then select then select AddAdd and and New Item…New Item….. [1][1] An An Add New ItemAdd New Item dialog box appearsdialog box appears.. [2][2]

2.2. In theIn the Add New ItemAdd New Item dialog box in thedialog box in the Categories:Categories: section, selectsection, select Visual C++Visual C++ andand CodeCode.. [2][2] In the In the Templates:Templates: section, select section, select C++ C++ file (.cpp)file (.cpp).. [2][2] In the In the Name:Name: text box, text box, [2][2] enter enter the name of the function (ex: main)the name of the function (ex: main).. [2][2] Click theClick the AddAdd button.button.

3.3. The function name appears in the The function name appears in the Solution Solution Explorer Explorer window under window under Source FilesSource Files and an area and an area opens to enter source codeopens to enter source code.. [3][3]

Page 8: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 8

Creating VS2005 Source File Creating VS2005 Source File (cont’d…)(cont’d…)

4.4. Enter source code in the open areaEnter source code in the open area.. [4][4]

5.5. When source code has been entered, select When source code has been entered, select FileFile and and Save AllSave All to save the source code to save the source code.. [5][5]

6.6. Note:Note: For header files, select For header files, select Header FileHeader File instead of instead of Source FilesSource Files in step 1 above and in step 1 above and select select Header File (.h)Header File (.h) instead of instead of C++ File C++ File (.cpp)(.cpp) in step 2 above. in step 2 above.

► SnapShots of Creating VS2005 Source SnapShots of Creating VS2005 Source FileFile

Page 9: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 9

Building Source Files to Building Source Files to ExecutableExecutable

1.1. From theFrom the BuildBuild menu, selectmenu, select Rebuild Rebuild SolutionSolution.. [1][1]

2.2. The results of the compilation are displayed The results of the compilation are displayed in the in the OutputOutput window window.. [2][2]

3.3. If there are errors indicated, make If there are errors indicated, make corrections then continue with step 5 on corrections then continue with step 5 on previous slide.previous slide.

► SnapShots Of Compiling in VS2005SnapShots Of Compiling in VS2005

Page 10: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

Running ProgramRunning Program

1.1. FromFrom thethe Debug Debug menu, select menu, select Start Without Start Without DebuggingDebugging.. [1][1]

2.2. A DOS window should open with the A DOS window should open with the program outputprogram output.. [2][2] After responding to After responding to program as directed and viewing the output, program as directed and viewing the output, press any key to continue.press any key to continue.

► To create a new project repeat above stepsTo create a new project repeat above steps..

► SnapShots of Running ProgramSnapShots of Running Program

10Visual Studio 200504/20/23

Page 11: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 11

Closing VS2005 Closing VS2005 Project/SolutionProject/Solution

1.1. FromFrom thethe File File menu, select menu, select Close Close SolutionSolution.. [1][1]

2.2. Respond to any message that may Respond to any message that may appear about saving changesappear about saving changes..

► The solution/project file structure can The solution/project file structure can be seen in slide be seen in slide [2][2]..

► SnapShots of Closing Project/SolutionSnapShots of Closing Project/Solution

Page 12: Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )

04/20/23 Visual Studio 2005 12

Opening an Existing VS2005 Opening an Existing VS2005 Project/SolutionProject/Solution

1.1. The entire solution folder (ex: sln_Test) can be The entire solution folder (ex: sln_Test) can be copied to another folder or device.copied to another folder or device.

2.2. In VS2005, selectIn VS2005, select OpenOpen Project/Solution… Project/Solution… from thefrom the FileFile menu.menu.

3.3. AnAn Open ProjectOpen Project dialog box appears.dialog box appears. Go to Go to

appropriate location of the project and selectappropriate location of the project and select the the appropriate appropriate FileName.FileName.slnsln file to open the file to open the solution.solution.

4.4. TheThe ProjectNameProjectName - Microsoft Visual 2005 - Microsoft Visual 2005

windowwindow withwith FileName.cpp FileName.cpp tab should appear.tab should appear.