Webocreation

Tuesday, November 17, 2009

Managing Your Projects

Managing Your Projects

Developer Studio incorporates several features to help you organize and manage your MFC projects. You work with these features in the Project Workspace window, where you view and modify your project. In the Project Workspace window, you can look at three different project-based views: ClassView, ResourceView, and FileView. You can also look at a documentation-based view called InfoView.

Developer Studio organizes all the project files in a location called the Project Workspace directory. The Project Workspace directory is the root directory for the project workspace.

In this section, you will learn about the project management features of Developer Studio. This section includes the following topics:


  1. Project Workspace Window
Once your application is loaded in the Developer Studio environment, you can choose your view of the project by clicking one of the tabs at the bottom of the Project Workspace window: ClassView, ResourceView, FileView, or InfoView.


The following table describes the four views available in the Project Workspace window.

View Description

ClassView Displays the project in terms of classes, not files.

ResourceView Displays all the resource files in the project and all the individual resource members included in each file.

FileView Displays all the files currently in the project workspace.

InfoView Displays the online documentation, as well as the MSDN Library, if it has been installed.

To see an illustration of the Project Workspace window for a sample project, click this icon.














  1. Using ClassView


® Adding new member functions

® Adding variables

® Adding virtual functions

To add a member function using ClassView

1. In ClassView, right-click the class to which you want to add a member function and click Add Member Function. The Add Member Function dialog box appears.

2. In the Function Type text box, type the function's return type.

3. In the Function Declaration text box, type the function declaration. The Function Type text box contains the return type for the function, so here you type only the function name, followed by a list of the names and types of formal parameters enclosed in parentheses.

4. Select an access specifier for the function from the Access group of options.

5. If you want a static function, click the Static check box. Or, if you want a virtual function, click the Virtual check box.

6. Click OK.

This procedure adds a declaration to the header file for the class, and a corresponding function body in the implementation file for the class.

To add a member variable using ClassView

1. In ClassView, right-click the class to which you want to add a variable and click Add Member Variable. The Add Member Variable dialog box appears.

2. In the Variable Type text box, type the Member Variable data type.

3. In the Variable Declaration text box, type the variable name.

4. Select an access specifier for the variable from the Access group of options.

5. Click OK.

To add a virtual function using ClassView

1. In ClassView, right-click on the class to which you want to add a virtual function and click Add Virtual Function on the shortcut menu. The New Virtual Override dialog box appears, prompting you with a list of virtual functions to add to the selected class.

2. If you click Add Handler, the dialog adds a stub function to the class's implementation file.

3. If you want to edit the virtual function you are adding, click Add and Edit; this navigates to the file in which the new virtual function is implemented.

4. If you want to edit an existing virtual function, select an item from Existing virtual function overrides, and click Edit Existing to navigate to the file in which the virtual function is implemented.

For more information about using ClassView features, see the Developer Studio online documentation.


  1. Project Workspace Directory
In the Developer Studio environment, a project is organized in a project workspace. A project workspace consists of a location — the Project Workspace directory — and files in that directory that describe the workspace and its contents.

The three project-based views discussed in the previous topic provide some innovative ways to visualize the structure of your project. The Project Workspace directory organizes your project in a more traditional manner by project directory and project files.

The Project Workspace directory is the root directory for the project workspace; all subsequent projects that you add to this project workspace are added in subdirectories under the Project Workspace directory. By default, Developer Studio selects the \Projects subdirectory under the Developer Studio installation directory as the Project Workspace directory. If you indicate a different directory for the project workspace, that directory becomes the default and all subsequent projects that you add are located under that directory. The Project Workspace directory contains several project-specific files:

® The project workspace file (.dsw). When you save a new project or update a current project, the .dsw file is created or updated, respectively.

® The project file for building a single project or subproject (.dsp).

® The workspace options file (.opt), which contains information about the local organization and appearance of the project workspace that is using your hardware and configuration.

For more information about project workspace files, see "Anatomy of a New Project" in the Developer Studio Environment User's Guide in the Visual C++ online documentation.

Usually, all source files associated with the first project are created in the Project Workspace directory. However, you can add source files to the project from any location without copying or moving them to this project.

For more information about files generated for Visual C++ projects, see "File Types Created for Visual C++ Projects" in the Visual C++ Programmer's Guide in the Visual C++ online documentation.


  1. opening an Existing Project Workspace

Opening an existing project workspace loads all project workspace information, and restores all environment settings to the state they were in when you last saved the project workspace.

To open an existing project workspace

1. On the File menu in Developer Studio, click Open Workspace.

The Open Project Workspace dialog box appears. The default selection in the List Files of Type drop-down list is Project Workspaces (.dsw, .mdp).

2. Select the drive and directory containing the project workspace that you want to open.

3. In the File Name list, select the .dsw file for the project workspace, and then click Open.

The Project Workspace window appears and displays views of the selected project in the workspace.


  1. Setting Project Build Options
When you build a project, you set the options for the project in the Project Settings dialog box.


To select options for building your project

1. Open the project.

For more information, see Opening an Existing Project Workspace in this chapter.

2. On the Project menu, click Settings.

– or –

In the FileView pane, right-click the project name, and then click Settings on the Context menu.

3. In the Project Settings dialog box, set the options for the project you are building.

New users usually use the default values, but you may want to customize the settings listed in the following table.

Use this tab For these settings

General To use MFC in a shared DLL or in a static library.

Debug To set the working directory for a project and provide program arguments at run time.

C/C++ To access a wide variety of settings, including warning levels, generating browse information, exception handling, the processor for which the application is built, and optimization.

For information about the other project settings tabs, see the online documentation for Visual C++.

No comments:

Post a Comment