Getting Started – Workspaces and Projects: (VC++)
Each application build is contained within a project The project structure encompasses all the source, header, and resource files necessary to build the application. It may import source or header files from other shared projects in the same workspace.
The workspace serves as a container for user preferences and other operational (session) settings that a user likes to keep common among similar projects. Also, it is possible that several application builds may share classes, resources, or other objects in common. To support this sharing, workspaces are defined so as to permit the inclusion of multiple projects.
When a workspace contains multiple projects, one of them is designated the current project. All Build, Debug, and other commands pertain to the current project.
Remember, workspaces contain projects, not the other way around.
Getting Started – new Workspace: (VC++)
When creating a new workspace, the default action for VC++ is to create a new subdirectory to contain the workspace that you are creating. It will have the same name as the name you give the workspace. You have the opportunity to override this by modifying the proposed pathname of the Location before completing the creation.
Default: new subdirectory for new workspace
In the directory where you want the new workspace to be placed, create the workspace as follows:
In thefield of the dialog, type in the name of the parent directory, or navigate to it. Fill in the field with the name of your choice. The field will automatically be updated to append this name to the current directory path as you type. Click .
Option: new workspace in existing directory
Create the workspace in an existing directory as follows:
Fill in thefield with the name of your choice. The field will automatically be updated to append this name to the current directory path as you type. Override this by entering the full path name of, or navigating to, the directory in which the workspace is to be formed. Click .
Note: Avoid putting more than one workspace in any directory. Control files which manage the workspace and its properties are placed in the directory, and this may cause confusion of option settings between several workspaces. It may also lead to name conflicts that could confound the IDE.
Getting Started – new Project in an existing Workspace: (VC++)
A simple, bare-bones application skeleton is automatically generated by the
function. This gives the user a quick start on getting together the minimal code and headers to
get started with minimal functionality. The dummy code will compile to a small, trivial application.
All the user has to do is add the code to make it do something useful. The kind of application
generated is selectable, anything from a simple
hello world console (text only) application
to a small fully-windows-based dialog.
New Project types:
When a New Project is created, the appropriate library paths, and compile and link options are
automatically set up according to the type of project selected. For example, a
Win32 Console Application - An application that supports MFC type of project has the libraries
for MFC included in the project settings, and appropriate headers are
#defined in the
A variety of application skeletons can be created:
- Win32 Console Application - empty project.
This just sets up an empty folder structure into which may be loaded or created the source files necessary to build the application.
- Win32 Console Application - simple application.
This creates a simple skeleton with only a single
mainfunction that returns 0.
- Win32 Console Application - A "Hello world" application
This creates a simple skeleton consisting of a
mainfunction with a single
- Win32 Console Application - An application that supports
This creates a simple
Hello Worldskeleton that says
Hello from MFC!. All of the extra goo that is necessary to link in MFC libraries and headers is included, and the character string is even tucked away in, and loaded from, the resource library. Output is performed via the
- Win32 Application - empty project.
This also sets up an empty folder structure into which source existing code may be loaded, and establishes the library paths and compile settings to support Windows-oriented builds.
- Win32 Application - a simple W32 application.
This project type creates a trivial skeleton that immediately returns. No window is opened. However, the entry point is properly set up as a Win32
WinMainentry, rather than as a console
- Win32 Application - a typical "Hello World!" application.
This sets up a simple skeleton that opens up a small resizeable window with the text
Hello World!displayed. The window supports a menu with an entry, and defines a program icon of two sizes.
There is a large variety of other project types for building AppWizards, Database projects, DLLs, makefile projects, and such. The two most useful types are the and the projects mentioned above.
Hello World Console Application:
As an example of how to create a project for your program, suppose you already have a VC++ Workspace created. Open this workspace. Then, starting from File menu, select:
Type the project name (this will become the name of the executable, and of the main .cpp file) in the indicated field, selectand then . On the next screen, select , then , and then .
Other project types are created in similar fashion.
Getting Started – new Project and Workspace: (VC++)
It is possible to create a project and a workspace all with a single action. In this case, the project files and the workspace files all appear in the same directory, rather than the project being stored in a subdirectory of the workspace. This is handy for a quick start, particularly if you are only going to do a single program, or know that you will want to have different user settings for this one program. But generally, this approach is best avoided in favor of setting up (at least) one workspace to contain all the favored user settings, and creating all projects subsequently under that.
First, make sure that no workspace is open. To do this, start at the File menu:
(In this example, suppose a Win32 console application is being created.) Starting from the File menu, select:
Type the project name in the indicated field. Make sure thefield has the path name of the desired parent directory. The button should be selected. Select . On the next screen, select , then , and then .
This puts both the workspace and the project in the same subdirectory, which is created with the same name as the project, and which is placed under the directory identified in thefield of the tab.
There are two main types of settings that a user may be concerned with, those which govern the building of the application code, and those which affect the IDE environment in which the user works.
Compile, Link, Libraries, Build Settings:
To change settings for compile options, link options, libraries and such, use:
Some useful options, and the tabs on which they appear are:
- Microsoft Foundation Classes:
This box must be checked so that browse information for each specific compiled file is generated. The check box on theBrowse Infotab must also be checked in order to use the browse information.
Insert symbols that need to be defined for the preprocesor here.
Insert any additional compiler switches needed here.
This is often the best choice. All headers are included and compiled each time a code file that
#includes it is compiled. (This eliminates theerror message.)
fatal error C1010: unexpected end of file while looking for precompiled header directive
- (the default setting)
Specify the name of the file. The default filename that
VC++sets up when you create a new project is
stdafx.h. If you have headers that are very seldom changed, and are commonly used throughout many source files, it might be advantageous to use precompiled headers. This way, the header is compiled once, and the compiler’s internal representation of that information is stored in a file, and simply reread when the
#includeis encountered, instead of recompiling the header. For large projects, this can save quite a bit of compile time.
Name additional object files and library files needed here.
Any additional link option switches may be added here.
- When browse info is built along with the program, editing and browsing of the source files is greatly simplified because the user can followhot linksfrom any object in the source file to its definition.
This directs that amasterbrowse file be created. This is necessary before any individual browse information files are usable for browsing.
IDE environment settings
To change settings for editor, debugger, workspace and such, use:
Particularly helpful options, and the tabs on which they appear are:
- / .
- This governs the appearance of the various types of window displays presented to the user: Source Windows, Debugger Windows, Watch Windows, etc.
- (type of window)
- . Foreground and background colors are selectable for each of various types of text.
- Text Selection
- Current Statement
- ...many others
Quick Start notes on MFC (VC++)
This section is a rough "quick notes" area for jotting down steps in getting a quick start with MFC.
This is for a simple application with dialog box, having buttons and
controls and fields, but without any
document associated with it.
Start in an open workspace and create a project
Enter the project name, selectand then . On the next screen, select , then . Select check boxes as appropriate. Defaults , , and are usually sufficient. Perhaps add . Click .
Just clickon the next screen. The defaults, , for source file comments, and for MFC library usage are usually what you want. The final screen gives you a chance to rename the application and dialog class the wizard creates you you. The names are derived from the Project name. You may rename the source files for the dialog class as well. Click .
Rememberfor the Project Settings, and set the box in tab, and in the .
Adding Controls to Dialog
When you first start up a new MFC project,
VC++ puts you into the resource editor with a new,
blank, dialog panel, populated with the default OK
/ Cancel / Help
buttons. You then add additional controls to this panel to create the dialog
Click first on the Controls toolbar, selecting the appropriate icon to identify what type of control is to be added to the dialog. The cursor changes to a cross-hair over the dialog panel. Click and drag to define the outline of the new control.
Controls may be resized and repositioned by selecting the control, then dragging the border of the control, or dragging one of the resize tabs in the centers and corners of the borders. The control may also be positioned coarsly by using the arrow keys.
Some degree of control over the positioning and sizing of controls is provided on the ctrl-arrow keys, which adjusts the group of selected controls so that the borders indicated by the arrow key are all aligned with the most extreme border in the group.menu. Multiple controls may be selected and then adjusted to have same alignment on a selected border, or same size, or various other properties in common. The most handy shortcuts are the
Pressing alt-Enter brings up the Properties dialog, in which on may set various properties of the control, like Visible, Disabled, Tab stop, and the like.
Associating Variables with Controls
Some controls have variables associated with them. For example, the Edit Box control provides an input field in which one line of text may be entered. A string variable may be associated with it such that changes to the field in the dialog appear in the variable, and changes in the variable appear in the field.
To associate a variable, referred to as a “Member Variable”,
with the control, secondary click on the control and select
Add Variable button, and complete
the name of the variable. This will become the
name of the variable.
Continuing ... TBD...