Marco Cantù 1998, Mastering Delphi 4
Project: WIZARDUI.DPR
Project Structure
WIZARDUI.DPR
program WizardUI;
uses
Forms,
WizForm in 'WizForm.pas' {WizardForm};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TWizardForm, WizardForm);
Application.Run;
end.
WIZFORM.PAS
unit WizForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ExtCtrls;
type
TWizardForm = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
Image1: TImage;
btnNext1: TButton;
btnNext2: TButton;
btnNext3: TButton;
btnNext4: TButton;
Bevel1: TBevel;
Label1: TLabel;
CheckInprise: TCheckBox;
btnBack: TButton;
Label2: TLabel;
Label3: TLabel;
CheckDone: TCheckBox;
Label4: TLabel;
Label5: TLabel;
CheckDone2: TCheckBox;
ListBox1: TListBox;
Label6: TLabel;
Label7: TLabel;
btnNext5: TButton;
procedure btnNext1Click(Sender: TObject);
procedure btnBackClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnNext2Click(Sender: TObject);
procedure btnNext3Click(Sender: TObject);
procedure btnNext4Click(Sender: TObject);
procedure btnNext5Click(Sender: TObject);
procedure LabelLinkClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
BackPages: TList;
public
procedure MoveTo (TabSheet: TTabSheet);
end;
var
WizardForm: TWizardForm;
implementation
{$R *.DFM}
uses
ShellApi;
procedure TWizardForm.btnNext1Click(Sender: TObject);
begin
if CheckInprise.Checked then
MoveTo (TabSheet2)
else
MoveTo (TabSheet3);
end;
procedure TWizardForm.btnBackClick(Sender: TObject);
var
LastPage: TTabSheet;
begin
// get the last page and jump to it
LastPage := TTabSheet (BackPages [BackPages.Count - 1]);
PageControl1.ActivePage := LastPage;
// delete the last page from the list
BackPages.Delete (BackPages.Count - 1);
// eventually disable the back button
BtnBack.Enabled := not (BackPages.Count = 0);
// move image and bevel
Bevel1.Parent := PageControl1.ActivePage;
Image1.Parent := PageControl1.ActivePage;
end;
procedure TWizardForm.FormCreate(Sender: TObject);
begin
BackPages := TList.Create;
end;
procedure TWizardForm.FormDestroy(Sender: TObject);
begin
BackPages.Free;
end;
procedure TWizardForm.MoveTo(TabSheet: TTabSheet);
begin
// add the last page to the list
BackPages.Add (PageControl1.ActivePage);
BtnBack.Enabled := True;
// change page
PageControl1.ActivePage := TabSheet;
// move image and bevel
Bevel1.Parent := PageControl1.ActivePage;
Image1.Parent := PageControl1.ActivePage;
end;
procedure TWizardForm.btnNext2Click(Sender: TObject);
begin
if CheckDone.Checked then
MoveTo (TabSheet5)
else
MoveTo (TabSheet3);
end;
procedure TWizardForm.btnNext3Click(Sender: TObject);
begin
if CheckDone.Checked then
MoveTo (TabSheet5)
else
MoveTo (TabSheet4);
end;
procedure TWizardForm.btnNext4Click(Sender: TObject);
begin
MoveTo (TabSheet5);
end;
procedure TWizardForm.btnNext5Click(Sender: TObject);
begin
Close;
end;
procedure TWizardForm.LabelLinkClick(Sender: TObject);
var
Caption, StrUrl: string;
begin
Caption := (Sender as TLabel).Caption;
StrUrl := Copy (Caption, Pos ('www.', Caption), 100);
ShellExecute (Handle, 'open', PChar (StrUrl), '', '', sw_Show);
end;
procedure TWizardForm.ListBox1Click(Sender: TObject);
var
StrUrl: string;
begin
StrUrl := ListBox1.Items [ListBox1.ItemIndex];
ShellExecute (Handle, 'open', PChar (StrUrl), '', '', sw_Show);
end;
end.
WIZFORM.DFM
object WizardForm: TWizardForm
Left = 213
Top = 134
Width = 470
Height = 259
Caption = 'WizardUI'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object PageControl1: TPageControl
Left = 0
Top = 0
Width = 462
Height = 232
ActivePage = TabSheet1
Align = alClient
TabHeight = 1
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'TabSheet1'
TabVisible = False
object Bevel1: TBevel
Left = 8
Top = 32
Width = 175
Height = 153
end
object Image1: TImage
Left = 16
Top = 40
Width = 153
Height = 139
AutoSize = True
Picture.Data = {...skipped...}
end
object Label1: TLabel
Left = 224
Top = 32
Width = 92
Height = 13
Caption = 'Delphi Web Wizard'
end
object btnNext1: TButton
Left = 368
Top = 184
Width = 75
Height = 25
Caption = 'Next'
TabOrder = 0
OnClick = btnNext1Click
end
object CheckInprise: TCheckBox
Left = 224
Top = 80
Width = 169
Height = 25
Caption = 'About Borland/Inprise site'
TabOrder = 1
end
end
object TabSheet2: TTabSheet
Caption = 'TabSheet2'
ImageIndex = 1
TabVisible = False
object Label2: TLabel
Left = 224
Top = 24
Width = 128
Height = 13
Cursor = crHandPoint
Caption = 'Main site: www.inprise.com'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ParentFont = False
OnClick = LabelLinkClick
end
object Label3: TLabel
Left = 224
Top = 48
Width = 149
Height = 13
Cursor = crHandPoint
Caption = 'Delphi: www.inprise.com/delphi'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ParentFont = False
OnClick = LabelLinkClick
end
object btnNext2: TButton
Left = 368
Top = 184
Width = 75
Height = 25
Caption = 'Next'
TabOrder = 0
OnClick = btnNext2Click
end
object CheckDone: TCheckBox
Left = 224
Top = 88
Width = 97
Height = 17
Caption = 'Done'
TabOrder = 1
end
end
object TabSheet3: TTabSheet
Caption = 'TabSheet3'
ImageIndex = 2
TabVisible = False
object Label4: TLabel
Left = 224
Top = 32
Width = 145
Height = 13
Cursor = crHandPoint
Caption = 'My site: www.marcocantu.com'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ParentFont = False
OnClick = LabelLinkClick
end
object Label5: TLabel
Left = 224
Top = 64
Width = 126
Height = 13
Cursor = crHandPoint
Caption = 'Publisher: www.sybex.com'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ParentFont = False
OnClick = LabelLinkClick
end
object btnNext3: TButton
Left = 368
Top = 184
Width = 75
Height = 25
Caption = 'Next'
TabOrder = 0
OnClick = btnNext3Click
end
object CheckDone2: TCheckBox
Left = 224
Top = 104
Width = 97
Height = 17
Caption = 'Done'
TabOrder = 1
end
end
object TabSheet4: TTabSheet
Caption = 'TabSheet4'
ImageIndex = 3
TabVisible = False
object Label6: TLabel
Left = 224
Top = 16
Width = 51
Height = 13
Caption = 'More sites:'
end
object btnNext4: TButton
Left = 368
Top = 184
Width = 75
Height = 25
Caption = 'Next'
TabOrder = 0
OnClick = btnNext4Click
end
object ListBox1: TListBox
Left = 224
Top = 40
Width = 193
Height = 121
Cursor = crHandPoint
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ItemHeight = 13
Items.Strings = (
'www.drbob42.com'
'www.iunknown.com'
'www.EckelObjects.com'
'www.informant.com'
'www.itecuk.com'
'sunsite.icm.edu.pl/delphi'
'www.delphiexchange.com')
ParentFont = False
TabOrder = 1
OnClick = ListBox1Click
end
end
object TabSheet5: TTabSheet
Caption = 'TabSheet5'
ImageIndex = 4
TabVisible = False
object Label7: TLabel
Left = 224
Top = 32
Width = 175
Height = 26
Caption =
'That''s all the information provided by the wizard. Thanks for us' +
'ing it.'
WordWrap = True
end
object btnNext5: TButton
Left = 368
Top = 184
Width = 75
Height = 25
Caption = 'Finish'
TabOrder = 0
Visible = False
OnClick = btnNext5Click
end
end
end
object btnBack: TButton
Left = 280
Top = 190
Width = 75
Height = 25
Caption = 'Back'
Enabled = False
TabOrder = 1
OnClick = btnBackClick
end
end
Copyright Marco Cantù 1998