making a wizard interface in delphi 7
Asked Answered
C

6

10

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?

Cultch answered 5/12, 2011 at 11:33 Comment(2)
Use TPageControl : delphi.about.com/od/delphitips2007/qt/hidepagectrltab.htmEnshrine
Project Jedi (JVCL) has a wizard component called TJvWizard.Synergy
G
20

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.

Gorlicki answered 5/12, 2011 at 11:39 Comment(4)
This is how I've done it in the past. Have a separate form for your wizard, with the page control and some buttons.Bonedry
i agree with this but also with LaKraven's idea to make a form per page, and dock the pages at runtime. Otherwise wizards tend to turn into a giant ball of spaghetti.Nne
@Warren LaKraven is actually suggesting frames rather than forms and I presume docking them at design time. But either way works and can be a very good technique to keep the spaghetti at bay, I agree.Gorlicki
For better results you could set DoubleBuffered to true.Out
F
14

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.

Forfeiture answered 5/12, 2011 at 11:49 Comment(5)
+1 but TNotebook is a bit of an oddity. It looks legacy to me and is perhaps a little harder to use.Gorlicki
I mention it because I cannot remember if TPageControl actually exists in Delphi 7 (I use it a LOT these days, but cannot remember ever seeing it circa Delphi 7)Forfeiture
Yes it was present in D7 and long before then tooGorlicki
Good to know :) TNotebook is in the Win 3.1 tab, so yes... I would suggest it's legacy ;)Forfeiture
great :) I'd strongly suggest marking David's as the correct answer, since mine is more an expansion on his ;)Forfeiture
U
11

JVCL has a good control to make a wizard in a very simple and effective way (TJvWizard). See http://jvcl.delphi-jedi.org/

Uncommunicative answered 5/12, 2011 at 13:9 Comment(1)
Agreed. Saves you a lot of time reinventing the wheel.Winker
M
4

You can give a try to these :

Marienbad answered 5/12, 2011 at 13:27 Comment(0)
M
2

You can test some components that can help you with this task (internally using tPageControl or TNotebook). See this link.

Regards.

Modicum answered 5/12, 2011 at 12:17 Comment(0)
C
0

You may also consider TMS TAdvSmoothStepControl (not free !). Another solution, but only 'external' to your program, is to use Inno Setup to make a Wizard, even for 'non installation setup' purposes.

In fact with Inno Setup you can make a lot of thinks ( modify .ini file and registry, start/stop programs...) that can be usefull for a wizard without 'installing' a program.

Chirrupy answered 5/12, 2011 at 18:9 Comment(2)
The last statement in your answer presumes the OP is trying to produce an Installation Wizard. The screenshots suggest otherwise. I suggest editing that part of your answer out and leaving the recommendation of TAdvSmoothStepControl (which is a nice component for sure)Forfeiture
@Forfeiture While the main use for Inno Setup is to create an installation setup, you may also use it (with some hack) as a Wizard for simple operations, like close a program, change .ini files according to user choices, and run the program again. May be it is not clear for all and I'll edit my answer.Chirrupy

© 2022 - 2024 — McMap. All rights reserved.