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 the
field 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 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. 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 New Project
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 #define
d in the
skeleton code.
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 singlemain
function that returns 0. - Win32 Console Application - A "Hello world" application
This creates a simple skeleton consisting of amain
function with a singleprintf
statement. - Win32 Console Application - An application that supports
MFC.
This creates a simpleHello World
skeleton that saysHello 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 theC++
functionscout
andcerr
. - 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 Win32WinMain
entry, rather than as a consolemain
entry. - Win32 Application - a typical "Hello World!" application.
This sets up a simple skeleton that opens up a small resizeable window with the textHello World!
displayed. The window supports a menu with an entry, and defines a program icon of two sizes. - others...
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.
Example 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, select
and 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 the
field 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 the
field of the tab.Settings (VC++)
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:
- .
- .
- Category:
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.- Category:
This is often the best choice. All headers are included and compiled each time a code file that#include
s 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 thatVC++
sets up when you create a new project isstdafx.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#include
is 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 follow
hot 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
- Text Selection
- Bookmark
- Current Statement
- Keyword
- ...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.
Dialog application
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, select
and then . On the next screen, select , then . Select check boxes as appropriate. Defaults , , and are usually sufficient. Perhaps add . Click .Just click
on 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 .Remember
for 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
box.
Placing Controls
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.
Positioning Controls
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 theControl Properties
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 C++
name of the variable.
Continuing ... TBD...
Tbd tbd.