Microsoft's Visual Studio

Projects:

A Visual ++ project consists of and resources. Data (like bitmaps, etc.) are stored in a resource file using established formats. The linker combines this binary resource file with the C++ compiled output to yield an executable file.

Resources include:

bitmaps cursors fonts icons keyboard-accelerator tables (like cntl-C to copy to the clipboard) menu definitions message-table entries dialog box layouts string-table entries version data user-defined data Resource

An application that creates a binary resource file based on the resource- definition file. The resource compiler can also append binary resource data to an executable file and create a resource table in the executable file's header. resource-definition file (*.rc)

A text file containing descriptions of an application's resources. The resource compiler creates a binary resource file based on the contents of the resource-definition file. Resource-definition files usually have a .RC extension. resource file (*.res)

A binary file created by the resource compiler that contains an application's resource data. Resource files usually have a .RES extension. resource object

An object file that consists of the resource file and the resource table. The linker links the resource object to the executable file. resource table

Data the resource compiler adds to the header of an application's executable file. This data includes the location, name, type, language, and so on, of each resource in the executable file. Resources:

You can work with resources that were not developed in Visual C++'s development environment or are not part of your current project. For example, you can:

•Work with nested and conditionally included resource files. •Update existing resources or convert them to Visual C++ format. •Import or export graphic resources to or from your current resource file. •Include shared or read-only identifiers (symbols) that can't be modified by the development environment. •Include resources in your executable (.exe) file that don't require editing (or that you don't want to be edited) during your current project, such as resources that are shared between several projects. •Include resource types not supported by the development environment.

You can open the types of files shown in the following table and edit the resources they contain.

Filename Description

.rc 16- and 32-bit resource script files .res 16- and 32-bit resource files .exe 16- and 32-bit executable files .dll 16- and 32-bit dynamic link library files .bmp, .dib, .ico, Bitmap, icon, and cursor files and .cur

Note Resource script files (.rc) are distinguished as being 16- or 32-bit by whether they contain 32-bit resource keywords (such as LANGUAGE, EXSTYLE, or DIALOGEX), not by their underlying file structure. You create a 32-bit .rc file only by adding 32-bit keywords to it.

The environment also works with the files shown in the following table during your resource editing session.

Filename Description

Resource.h Header file generated by the development environment; contains symbol definitions.

filename.aps Binary version of the current resource script file; used for quick loading.

projectname.clw File containing information about the current project; used by ClassWizard in Visual C++. projectname.mak File containing project build instructions. projectname.vcp Project configuration file. Resource Scripts (.rc)

These a text files that look C++/C-ish. They can contain:

Macros (#define and #undef)

Conditional compilation (#if, #ifdef, #ifndef, #else, #elif, #endif)

Header files (#include)

C/C++ comments (/* … */ and // )

Stringizing operators (#)

Token-passing operators (##)

Single line statements:

Bitmaps:

name BITMAP name.bmp

Cursors:

name CURSOR name.cur

Fonts:

name FONT name.fnt

Icons:

name ICON name.ico

Language (like english)

Messagetables (used in NT for event logging)

Multiline statements:

Accelerators - these are keystrokes that represent shortcuts to specific tasks.

name ACCELERATOR BEGIN "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT ;^C "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT ;^V "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT ;^X VK_F1, IDDCLEAR, VIRTKEY ; F1 VK_F1, IDDSTAR, CONTROL, VIRTKEY ;control F1 VK_F1, IDDCLEAR, SHIFT, VIRTKEY ;shift F1 END

Dialogs - these are the main input type windows like:

There are two types of dialogs.

Modal dialogs - the user MUST respond before anything else can happen. The application is suspended otherwise.

Modeless dialogs - the application is not suspended. name DIALOG 20, 20, 90, 64 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Sample Dialog" BEGIN DEFPUSHBUTTON "Sample Button", IDOK, 19,44, 52, 14, WS_GROUP CTEXT "Sample Message", -1, 0, 8, 90, 8 END

Menus - menu bars and pop-up menus. name MENU BEGIN POPUP "&File" BEGIN MENUITEM "&New\tCtrl+N", ID_FILE_NEW MENUITEM SEPARATOR MENUITEM "E&xit", ID_FILE_EXIT END POPUP "&Edit" BEGIN MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY MENUITEM "Paste\tCtrl+V", ID_EDIT_PASTE END POPUP "&Help" BEGIN MENUITEM "&About", ID_HELP_ABOUT END END

String tables - strings that the program uses can be accessed from here to support multiple languages.

STRINGTABLE BEGIN IDS_HELLO "Hello" IDS_GOODBYE "Goodbye" END

Toolbars - a toolbar is an icon-like alternative to the menu.

IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_FILE_NEW BUTTON ID_FILE_OPEN BUTTON ID_FILE_SAVE SEPARATOR BUTTON ID_EDIT_CUT BUTTON ID_EDIT_COPY BUTTON ID_EDIT_PASTE SEPARATOR BUTTON ID_FILE_PRINT BUTTON ID_APP_ABOUT END

Version Information -

User-defined and raw data resources - just data that can be used by the program. AppWizard

Here's an easier way to get it all going. Call this FirstGUI.

File New MFC AppWizard (exe) Just select all default options

The following files and directory are automatically generated:

FirstGUI.clw ReadMe.txt FirstGUI.dsw FirstGUI.h FirstGUI.cpp StdAfx.h StdAfx.cpp MainFrm.h MainFrm.cpp ChildFrm.h ChildFrm.cpp FirstGUIDoc.h FirstGUIDoc.cpp FirstGUIView.h FirstGUIView.cpp Resource.h FirstGUI.rc FirstGUI.ncb FirstGUI.dsp FirstGUI.opt RES

FirstGUI.rc2 FirstGUIDoc.ico FirstGUI.ico Toolbar.bmp

The Readme.txt file has the following info:

======MICROSOFT FOUNDATION CLASS LIBRARY : FirstGUI ======

AppWizard has created this FirstGUI application for you. This application not only demonstrates the basics of using the Microsoft Foundation classes but is also a starting point for writing your application.

This file contains a summary of what you will find in each of the files that make up your FirstGUI application.

FirstGUI.h This is the main header file for the application. It includes other project specific headers (including Resource.h) and declares the CFirstGUIApp application class.

FirstGUI.cpp This is the main application source file that contains the application class CFirstGUIApp.

FirstGUI.rc This is a listing of all of the resources that the program uses. It includes the icons, bitmaps, and cursors that are stored in the RES subdirectory. This file can be directly edited in Microsoft Developer Studio. res\FirstGUI.ico This is an icon file, which is used as the application's icon. This icon is included by the main resource file FirstGUI.rc. res\FirstGUI.rc2 This file contains resources that are not edited by Microsoft Developer Studio. You should place all resources not editable by the resource editor in this file.

FirstGUI.clw This file contains information used by ClassWizard to edit existing classes or add new classes. ClassWizard also uses this file to store information needed to create and edit message maps and dialog data maps and to create prototype member functions.

//////////////////////////////////////////////////////////////////////

For the main frame window:

MainFrm.h, MainFrm.cpp These files contain the frame class CMainFrame, which is derived from CMDIFrameWnd and controls all MDI frame features. res\Toolbar.bmp This bitmap file is used to create tiled images for the toolbar. The initial toolbar and status bar are constructed in the CMainFrame class. Edit this toolbar bitmap along with the array in MainFrm.cpp to add more toolbar buttons.

/////////////////////////////////////////////////////////////////////

AppWizard creates one document type and one view:

FirstGUIDoc.h, FirstGUIDoc.cpp - the document These files contain your CFirstGUIDoc class. Edit these files to add your special document data and to implement file saving and loading (via CFirstGUIDoc::Serialize).

FirstGUIView.h, FirstGUIView.cpp - the view of the document These files contain your CFirstGUIView class. CFirstGUIView objects are used to view CFirstGUIDoc objects. res\FirstGUIDoc.ico This is an icon file, which is used as the icon for MDI child windows for the CFirstGUIDoc class. This icon is included by the main resource file FirstGUI.rc.

////////////////////////////////////////////////////////////////////

Other standard files:

StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named FirstGUI.pch and a precompiled types file named StdAfx.obj.

Resource.h This is the standard header file, which defines new resource IDs. Microsoft Developer Studio reads and updates this file.

/////////////////////////////////////////////////////////////////////

Other notes:

AppWizard uses "TODO:" to indicate parts of the source code you should add to or customize.

If your application uses MFC in a shared DLL, and your application is in a language other than the operating system's current language, you will need to copy the corresponding localized resources MFC40XXX.DLL from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC40DEU.DLL contains resources translated to German.) If you don't do this, some of the UI elements of your application will remain in the language of the operating system.

////////////////////////////////////////////////////////////////////

Compile and Run this program. You'll get the following (pretty impressive!):