Search code examples
delphidelphi-7wizard

making a wizard interface in delphi 7


I'm using delphi 7 and I'm trying to make a wizard interface. I don't know if there is an easier way to make a wizard, so I was thinking of making separate forms for each step of the wizard, and when the user clicks "Next" the active form closes and the next one opens.

Here's a screen-shot of two successive forms: screen-shot

I've made a procedure that take 2 forms as parameters: the form that will be closed and the next form of the wizard

class Procedure Tspad.nextForm(showForm, closeForm: TForm);
begin
   closeForm.Close;
   showForm.Showmodal;
end;

When I click the "Next" Button the folowing code is executed:

Tspad.nextForm(echipContractForm, clientContractForm);

When i run the program, and i press the "Next" button, the next form apeares but the curent one dosen't close.

How can i make this work, or is there another more efficient way to create a wizard?


Solution

  • One very common way to make a wizard is to use a page control. Each distinct page of the wizard is a different page/tabsheet in the page control. I believe that this is effectively how Windows implements wizards.

    Naturally you want to hide all the tabs. Do this by setting TabVisible to False for each tabsheet. When you wish to move forwards and backwards through the wizard, e.g. when the user clicks the next or previous buttons, effect this by setting ActivePage or ActivePageIndex depending on your preference.