Visual C ++. Net Chapter 4

xiaoxiao2021-03-06  104

Chapter 4

Visual C . Net Wizards

Visual C . Net wizard

Developing for the Microsoft platform involves a lot of boilerplate coding. Back in the early days of Windows development, most developers started a Windows-based Project armed with only a copy of Charles Petzold's Programming Windows and the Windows Software Development Kit (SDK). Even The Windows SDK Documentation Recommended The Editor Inheritance Method of Application Developments.

To understand the fundamental underpinnings of any technology, you have to write all the code for an application. But there comes a time when writing the same boilerplate again and again becomes merely a drill and a waste of time. To address this issue, the Microsoft Visual Studio.NET environment provides a set of code generators to start you off on all types of projects. The available project templates appear in the New Project window when you choose New, Project from the File menu. you select the project template you want, Run THROUGH The Dialog Boxes To Configure The Project, And Click Finish. Voila-You'Ve Got A Working Application.

But that's not the end of the story. The wizard technology is extensible you can write your own wizards. This chapter gives you a rundown of Visual Studio.NET 's wizards and explains how to write your own.

There are many template code in the development of the Microsoft platform. In the early Windows development, many developers learn Charles Petzold's Windows programming and Windows Development Kit code to start their Windows project. Each Windows SDK file recommends developers Use inherited methods to apply to the application development.

To understand the basic principle of each technology, you have to write all the code in the app. But sometimes it turns into the practice and waste time when you repeat the same model code. To solve this problem, Microsoft The VS.NET environment provides a code generator settings to keep away from the same type of item. In the file menu project, select New, available item templates appear in the new project window. You choose the project according to your needs. Template, the project configuration in the Quick Handling Configuration dialog box is done. That is --- you get a work that can work.

But the story is not ending. This guide technology can be customized according to your needs. This chapter will tell you the outline of vs.net's wizard and explanation how to build your own wizard.

Wizard Types

Visual Studio.NET supports two types of wizards:. Those with a user interface and those without Depending on the complexity of your wizard, you might want to include a user interface Most of the wizards you'll see in this book include one.. for example, the MFC Application Wizard includes several pages that provide such options as type of document interface (SDI or MDI), whether to support printing and print preview, and whether to use ActiveX controls. for simple application types. You might not need a user interface.Wizards without user interfaces simply take a project name you supply and generate project files based on templates you provide. Wizards with user interfaces tend to be a little more involved and can include several pages of application options.

In Fact, The Source Code for All The Visual C . Net Wizards Is Available. You Can Find The Wizard Source Code Files in The / Program Files / Microsoft Visual Studio.Net/vc7/vcwizards Directory.

Wizard type

VS.NET supports two types of wizards: there is user interface and no user interface. Relying on the complexity of the wizard, you can build a user interface. Many guides you can see in this book. For example, MFC The Application Wizard contains several pages to provide such options for document interface (SDI or MDI), whether to support print and print previews, use ActiveX controls. Simple application types, you do not need user interface.

The wizard without the interface can only be simple to provide the project name to produce project files that you can provide. There is a wizard of the user interface to trouble, it consists of several pages to provide options for the application.

In fact, the source code of the VC . NET wizard is available. You can find the source code file in the / program file / microsoft visual studio.net/vc7/vcwizards directory.

How Wizards Work

Before we create a wizards work. We'll Look at The Three Main Parts of a Wizard: The Original Boilerplate Code, The User Interface, and The Code Iterates.

The general idea behind a code generator is to create a basic project for you to relieve you from having to type all the boilerplate code. That basically means a bare-bones application or library that works and compiles. However, you want the code to reflect the nature of the project. For example, if you're writing a payroll application, you want the classes in the application to have names like CPayrollDoc, CPayrollView, and CPAYROLLfRAME. It's the wizard's job to substitute the plain vanilla names of the basic application with the names the developer types in.The wizard is also responsible for adding or leaving out certain parts of code, depending on the developer's selections. for example, if you select the About dialog box from a list of options, the wizard will add the Correct code for the dialog box to the finished application.

The wizard presents these choices through a user interface. The heart of the wizard's interface is an HTML control named IVCWIzCtrlUI. The Visual Studio.NET wizards use HTML to drive the user interface. When you execute the wizard, the IVCWizCtrlUI interface looks for the list of files representing the user interface and displays those pages within the wizard. The wizard is responsible for managing navigation through each of the pages as well as generating the code when the developer clicks the Finish button.

A wizard can contain any number of pages, each driven by a separate HTML file. The wizard provides navigation functionality through the Next and Back buttons (or any other format you specify). The HTML files that implement the wizard interface contain the SYMBOL tag, Which Identifier The Default for Developer-Defined Options.

How is the wizard work?

Before we establish a wizard, let's take a look at how the wizard work. We will consider the three main parts of the wizard: the original model code, user interface and code generation. Generally speaking, the code generator creates basic project to help you All types of sample code. Basically, an empty-neck application or library. However, you want code to reflect a realistic project. For example: You want to write a salary application, you want the app's class similar to CPAYROLLDOC, CPAYROLLVIEW and Name of CPAYROLLFRAME. Wizard work is to replace the name of the application with the name entered by the developer.

Relying on the selection of developers, the wizard is also responsible for increasing or removing some of the code. For example, you selected the dialog from the list option, the wizard will complete the application for the additional code for the dialog box.

The wizard is now selected. The core of this wizard interface is a HTML control called IVCWizCtrlui. Vs.NET uses HTML to drive the user interface. When you execute the wizard, the IvcWizCtrlui interface looks for a list file that expresses the user interface and displayed The wizard page. When the developer clicks the completion button, the wizard is responsible for managing and generating the appropriate code for each page.

The wizard contains a lot of separate HTML pages. The wizard provides navigation features (or any way you define) through the Next and Back button. The HTML file that implements the wizard interface contains the Symbol flag, those that are the default default defaults of the developer definition option.

The Wizard Maintains a Symbol Table During The Lifetime of Its Execution.

The symbol table is just a dictionary lookup mechanism for making substitutions The symbols declared in the HTML file are written into the symbol table when the user clicks Finish For example, examine the following HTML in a wizard user interface..:

In the wizard user interface, the text box represents an input box for the user to type into. The text box is identified using the symbol SOURCE_FILE. This is the key the wizard will look for when it makes substitutions for source files. We'll LOOK AT HOW THAT WORKS in Just a Minute. Basically, Each HTML File Used by The Wizard Is Responsible for Recording User Selections To The Symbols Table.

Logic within the wizards is usually implemented using Jscript. If you need to provide customized behavior from within the wizard, you can use Jscript functions to access the Visual C Wizard Model. These functions are in the HTML page section headed