Freigeben über


Visual Basic Concepts

Wizards and the Wizard Manager

A Wizard is a tool which leads a user step-by-step through an unusually long, difficult, or complex programming task. If you want to create Wizards that look and act similarly to those used in Microsoft products, you can use the Wizard Manager.

First, let's clarify what the Wizard Manager does not do. It does not automatically create complete, functional Wizards. This makes sense, because it's up to you, the programmer, to decide what your Wizard will do. What it will do for you is create a framework of steps in your Wizard, and help you manage the order in which they will appear when the Wizard is run. You add your code to the framework to perform the actual tasks. The resulting Wizards look and operate like other Wizards.

How the Wizard Manager Works

Programmatically, a Wizard is a form which contains a variable number of frames (or "steps"), each of which comprises a step to completing a Wizard’s task. For example, one step of a Wizard might allow the user to choose a style for an output report, such as Classic, Modern, and so on, while the next screen might allow the user to decide how and where to display fields on the report.

The Wizard Manager uses only one form for the entire Wizard. This form (which must be named "frmWizard") has a visible area that is the same size as each step frame. When a step is presented, its Left property is set to that of the visible area of the form, making it visible to the user. The Left properties of steps not in use are set away from the visible area of the form. You can think of it like viewing a stack of pictures from a nearby table, where you place one picture at a time in front of you to view it, then return it to the stack on the table when you’re done. In similar fashion, the current step is moved to the visible area, then moved away to the "storage" area when you move to another step.

All About Steps

When you first start the Wizard Manager, you're provided you with a preset "stack" of steps as a starting point. These steps are: Introduction, Step x, and Finished!.

  • The Introduction step, which usually contains a graphic of some sort, is used for informing the user about the name and function of the Wizard, or any other information you want to impart.

  • The Step x steps are a set of four generic, template-like steps that you can replicate or delete as many times as needed. These steps form the bulk of the Wizard and are where questions are asked, input gathered, calculations made, properties changed, and so forth. Four identical generic steps are initially provided for your use. You may require more or less steps, depending on what you want your Wizard to do.

  • The Finished! step, which contains a picture of a checkered flag, is the last step of the Wizard and is normally displayed when all of the steps of the Wizard are complete, alerting the user that they've completed the task.

Each step provided by the Wizard Manager consists of three areas:

  • An Image control   The Image control is located in the upper left corner of the step and is used to display a graphic for that step, if desired.

  • A Label control   The Label control is located in the upper right corner of the step and is normally used to display instructions to the user about what to do in that step.

  • A TextBox control   The TextBox control is located in the bottom half of the step and is normally used to display additional information to the user. Alternatively, it can be deleted and other controls placed there instead.