Webocreation

Tuesday, November 17, 2009

MFC Wizards ((cont. chapter 3))

MFC Wizards

Developer Studio includes many wizards that do much of the work required to create an application. The following table describes the wizards that you use most in developing MFC applications.

Wizard type Description

AppWizard Generates a complete set of source files and resource files based on classes from the MFC Library.

ClassWizard Automates the creation and editing of classes, and creates additional classes based on MFC.

Custom AppWizard Creates the starter files for a custom project. You can create custom AppWizards based on one of the three categories: an existing project, the standard MFC AppWizard steps, or your own custom steps.



ActiveX ControlWizard Creates a set of starter files for an ActiveX control.



ATL Wizards Create an Active Template Library (ATL) project and add ATL COM objects. The easiest way to create an ATL project is to use ATL COM AppWizard. You can then add objects or controls to your project using ATL Object Wizard.



DLL Add-InWizard Creates classes for the DLLs you add to your Visual C++ project. For more information, see "Developer Studio Add-Ins" in the online documentation.



ISAPI Extension Wizard Creates a set of starter files based on MFC and provides the classes that wrap ISAPI to create and handle Internet server extensions and filters.



WizardBar Can be used in Visual C++ with dialog boxes to attach code to the visual elements of your application.



In this section, you will learn how to use AppWizard and ClassWizard to create and modify a project in the Microsoft Developer Studio environment. AppWizard and ClassWizard create the basic framework (a set of starter files) for your project, and then you refine the project by modifying its classes. For information about using the other wizards, see Mastering MFC Development Using Visual C++ 5, listed in the Library.



This section includes the following topics:



  1. Using AppWizard


AppWizard is a powerful, flexible tool you can use to create many types of Windows-based applications. When you start a project, you can use AppWizard to quickly create an executable file (.exe), a dynamic-link library (.dll), or other component.



To see an illustration that shows the types of projects you can create in Microsoft Visual C++, click this icon.







AppWizard creates a working set of starter files for your application with significant built-in functionality. You select the type of application or component you want, and AppWizard creates the necessary files for a Windows-based application.



In AppWizard, you follow a series of steps in which you choose options for your project. The steps and options displayed depend on the application or component type you select. You can move forward and backward through the steps and make changes until you are ready to create the application. The following illustration shows the initial screen in AppWizard.







To see a demonstration of how to create a project and MDI application in AppWizard, click this icon.



b



u To create a new project and application



1. Start Visual C++.



2. On the File menu, click New. In the New dialog box, click the Projects tab.



3. From the list of project types, select MFC AppWizard (EXE) or MFC AppWizard (DLL) to create a project based on the MFC Library.



4. In the Project name text box, type a name for your project.



5. In the Location text box, type the path for the directory where you want your project directory to be created. You can use the Browse button to search for a directory.



6. Click OK to create a project workspace. With the workspace structure created, AppWizard displays either the AppWizard .exe file options or the AppWizard .dll options, depending on which project type you chose.



When you have finished defining application and project options, AppWizard generates the starter files necessary to build a Windows-based application. These starter files include source files, header files, resource files, a project file, a Readme file, and so on. The Visual C++ source files contain skeletal versions of the classes that make up your application. This AppWizard code is compatible with ClassWizard to simplify your development work.



  1. ClassWizard


ClassWizard simplifies using the MFC classes, making it easier for you to perform various routine programming tasks.



ClassWizard works with MFC message maps, Automation dispatch maps, and the DoDataExchange member function of your application's dialog class. You can use ClassWizard only with applications that use MFC.



With ClassWizard, you can:



® Create new classes, derived from many of the main framework base classes, which handle Windows messages and recordsets.



® Map messages to functions associated with windows, dialog boxes, controls, menu items, and accelerators.



® Create or delete message-handling member functions.



® Determine which messages already have message handlers defined, and jump to the handler application code.



® Override MFC virtual functions.



® Define member variables that automatically initialize, gather, and validate data entered into dialog boxes or form views.



® Simplify working with ActiveX and database classes.



® Add Automation methods and properties when creating a new class.



In Chapter 6: Handling Messages, you will use ClassWizard to add, modify, and delete message handlers.



  1. WizardBar


The WizardBar is a toolbar that contains a subset of the functionality available in ClassWizard. The WizardBar provides shortcuts to ClassWizard to simplify routine tasks, such as defining message handlers, overriding MFC virtual functions, and navigating in an implementation (.cpp) file. Like ClassWizard, the WizardBar works only with applications that use MFC.



With the WizardBar, you can:



® Browse the Windows messages associated with windows, dialog boxes, controls, menu items, and accelerators.



® Create and edit message-handling member functions.



® Determine which messages already have message handlers defined, and jump to the handler program code.



® Jump to a header file.



To view the WizardBar, right-click in an unused portion of the Developer Studio menu bar. On the shortcut menu that appears, click WizardBar. The following illustration shows a sample display of the WizardBar.



b



Note The WizardBar remains inactive unless you have a project open.

For more information about using the WizardBar, see Handling Messages with the WizardBar in Chapter 6: Handling Messages and the Developer Studio online documentation.

No comments:

Post a Comment