Image of Navigational Map linked to Home / Contents / Search How to write Delphi Wizards

TSysInfoExpert
Image of Line Break

Instead of just popping up a MessageDlg, we can show any form we'd like. In fact, this is just were the fun starts. Generally, we can consider our Wizard to consist of two parts: the Wizard engine and the form interface. We've just seen how to write the Wizard engine, and we all know how to write form interfaces, so let's put these two together and write our first something-more-than-trivial information Wizard. The information that I want the Wizard to present can be found in the SysUtils unit, and consists of the country specific informatin regarding currency and date/time formatting constants. In the on-line help we can find which constants are defined in SysUtils, but we can't see their value. This is unfortunate, since most of the time Delphi is of course up-and-running while we're developing, so SysUtils is active as well (remember: Delphi is written in Delphi!) and should know about these values.

So, using the Dialog Expert, we can create a Multipage dialog, using a TabbedNotebook, and give the three pages the names "Currency", "Date" and "Time". Next, we must drop a label on each of the pages, set autosize for each label to false, and make them about as big as the entire notebook (so multiple lines can be viewed). The source code for the form merely consists of putting the right values on the right places when the form is created (in the OnCreate handler), so nothing complex at all for the interface side of the SysInfo Wizard. The engine of TSysInfoExpert is as follows:

TSysInfoExpert
GetStyle:esStandard
GetIDString:DrBob.TSysInfoExpert
GetName:SysInfo Wizard
GetAuthor (win32):Bob Swart (aka Dr.Bob)
GetMenuText:&SysInfo Wizard...
GetState:[esEnabled]
GetGlyph:0
GetPage (win32): 
GetComment: 

The Execute method of the SysInfo Wizard is almost as easy, since all we need to do is to create, show and free the form with the desired information. That's it. The source code for the Execute procedure is as follows:

  procedure TSysInfoExpert.Execute;
  begin
    with TSysInfoForm.Create(nil) do
    begin
      ShowModal;
      Free
    end
  end {Execute};
And presto! Our first "useful" Wizard, showing information at design time that isn't available any other way:

This is only the first of many examples where we will see an Wizard engine that will show an interface form to show (or get) information to the user. One source of information to provide (or actions to apply) can be obtained from the so-called toolservices interface Delphi offers us in the TIToolServices class.


Image of Arrow linked to Next Article Image of Arrow linked to Next Article
Image of Line Break
[HOME] [TABLE OF CONTENTS] [SEARCH]