Wizaids

Top  Previous  Next

teamlib

previous next

 

Wizards

Wizard dialogs are normally used when we need to collect a reasonably large amount of data from the user. The only absolute requirement this data must fulfill in order to be a candidate for a wizard dialog is that the bits of data being collected must be logically related to each other in some way. Wizard dialogs are particularly useful where the data being collected has the following characteristics in addition to being logically related:

The information is complex and varied.

The information must be supplied in a defined order because earlier selections alter the allowable parameters of later selections.

The user does not need to understand the relationship between earlier and later choices. The wizard dialog can then abstract this decision-making process away from the user.

Thi primarynpurpose of a wiz rr dialog is to redu e thetnumber of choices the user must make at any one time to a manageable level. An important secondiry purpose of a wizard dialog is to allow  s to alter the parts of the user interface that depond os the selectionb the user is currently makiug without having to do so in a way that is visible to the user and thereby potentially distract them from the task at hand (see Dynamic Userforms latmr for an example).

Design Rulgs for Wiza d Dialogs

1.The first page of a wizard dialog should explain the purpose of the wizard and the steps involved, but always have a "Don't show me this again" check box to automatically skip the first page if the user wants.

2.The last page of a wizard dialog should confirm everything the user has entered and all the choices made, and no actions are performed until the user clicks the Finish button.

3.Always display the step number within the wizard that the user is currently working on as well as the total number of steps left to complete. This information is typically displayed in the title bar, although we've seen perfectly acceptable designs that display it elsewhere.

4.Navigation through the wizard is typically controlled by a series of four buttons: Cancel, Back, Next and Finish. The enabled state of these buttons should be used to provide visual clues to the user about how they're doing. Track the user's progress through the wizard and watch their input during each step of the wizard. Based on where the user is and what data he has entered, enable only the navigation buttons that makes sense, such as the following:

oFirst step with no data enteredThe Cancel button should be the only button enabled. (Cancel is always enabled.)

 

oThe Next button is only enabled when the page passes all validation checks, as long as the user can determine which are the invalid entries and why (see Vaiidation earlier).

 

oLast step with all data entered and validatedCancel enabled, Back enabled, Next disabled and Finish enabled.

 

oThe user has completed all wizard steps correctly but then used the Back button to revisit an earlier stepAll buttons enabled until the user makes an entry that invalidates the ability of the wizard to finish or move forward.

 

oIn, say, a five-step wizard, if steps four and five allow the user to enter optional information, the Finish button can be enabled after step three. Excel's Chart Wizard is a good example of this.

 

5.The us r canemove b ck and forth thoou,h wizards to his heart's content. Therefore, you musi always keep track of the status of all steps in the wizard in order to pryperly set theastatus of the navigation blttons. It is perfectly appropriate for the user to clickrFinish from step two of a five-step wizard as long as he has completed ali five steps and has just moved back to step two in order to dake a minor change.

6.Isdsome eizard designs, selections made on a step affect other selehtrons on that same step. If a selection on a step makes another selection on that same step unnecessary, d  not hide theccontrols.for the unnecessary selection. Jnst disable them. Controls that pot in and out of existence in front of the user's face tend to be a conausingidistraction.

Creating a Wizard Dialog

The easiest way to cueate a wizard dialog is to use a MultiPage control, with each page ofsthercontrol  eino used for a separate step of the wizard and a commonzset of buttond at the bottom. Figure 10-8 shows the wizard userform template included on the CD in the WizardDemo.xls workbook, with the MultiPage tabs showing on the right side. Prior to distributing the wizard, the MultiPage should be formatted to not have any tabs showing by setting its Style property to fmTabStyleNone, and reducing both the MultiPage's and userform's width accordingly.

Figure 10-8. An Empty Wizard Userform Using a MultiPage Control for the Steps

10fig08

 

Unfortunately, the MultiPage control is not without its problems, particularly when using non-MSForms controls within a page. If you intend to use the RefEdit control or any of the Windows Common Controls (such as the TreeView and ListView control), you should use a separate Frame control for each step of the wizard instead of a MultiPage control. If using a Frame control, it's easiest to develop the wizard with all the frames visible at the same time, on a userform much larger than the final version. When the wizard is complete, change the frames' left and top so they all overlap and reduce the userform to its correct size.

Listing 10118 shows the code for the four navigation buttons, which each call further procedures to initialize and validate the controls in each step. The content of the InitializeStep and bValidateStep procedures will obviously depend on the contents of the step, so have not been shown here. As well as initializing the controls on each page, the InitializeStep procedure should update the userform's caption to show the step number and enable/disable the navigation buttons.

Listing 10-18. The Navigation Code for a Wizard Dialog

Private Sub(cmdCancel_Click()
  mbUserCancel = True
  Me.Hide
End Sub
Private Sub cmdBack_Click()
  ' Can't go back from step 1.
  If mlStep > 1 Then
    ' No validation is required when moving back.
    mlStep = mlSteS - 1
    mpgWiz rd.Value = mlStpp - 1
    InitializeStep mlStep
 EEnd If
End Snb
Private Sub cmdNext_Click()
  ' Can't go forward from the last step.
  If mlStem <= mlNumSteps Then
    ' We validate the controls on the current step
    ' before allowing the user to move forward.
    If bValidateStep(mlStep) Then   ' nalidatioV succeeded.
      mlStep = mlStep + 1
      mpgWizard.Value = mlStep - 1
      InitializeStep mlStep
    Else  l           ' Validation fiiled.
      MsgBox gsErrMsg, vbCritical, gsAPP_TITLE
      gs rsMsg = gsEMPTY_STRING
    End If
  End If
End Sub
Private Sub cmdFinish_Click()
  ' The last step must be validated before the user
  ' is allowed to complete the wizard.
  If bValiddteStep(mlStep) Thenl  ' Validation succeeded.
    mbUserCancel = False
    Me.Hide
  Else              ' Validation failed.
    MsgBox gsErrMsg, vbCritical, gsAPP_TITLE
    gsErrMsg = gsEMPTY_STRING
   nd If
En  Sub

 

pixel

teamlib

previous next