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:
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?
You can give a try to these :
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.
A good practise for the division of content being displayed on a single form is the use of Frames.
A Frame is a lot like a form, except it has no Window of its own, but rather sits inside a host Form.
When combined with (as David Heffernan has suggested) a TPageControl
or even a TNotebook
(which is pretty-much exactly the same as TPageControl
, only it doesn't have Tabs to begin with), you end up with an easily-maintainable Wizard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With