[Lazarus] multi step dialog

Marc Santhoff M.Santhoff at web.de
Mon Aug 17 15:56:46 CEST 2015


On Mo, 2015-08-17 at 09:34 +0100, Tony Whyman wrote:
> On 17/08/15 07:59, Graeme Geldenhuys wrote:

> > In fpGUI I simply use a PageControl and set TabPosition = None. In
> > Delphi 5-7 and Kylix I used to do similar, but can't remember what exact
> > control I used... might have been PageControl too.

> A TPageControl is also what I use to get a multi-step dialog.
> 
> Set "ShowTabs" to false and make each step a page in the pagecontrol. 
> The Form's OnShow Handler should set the initial tab index e.g.
> 
> PageControl1.TabIndex := 0;
> 
> Place the forward/back buttons outside of the pagecontrol and make the 
> body of each button's "OnClick" handler a case statement
> e.g.
> 
> case PageControl1.TabIndex of
> 0: begin
>        {validate}
>       PageControl1.TabIndex := 1;
>     end;
> 1: begin
>        {validate}
>       PageControl1.TabIndex := 2;
>     end;
>    ...
> end;
> 
> The final step should set the ModalResult.
> 
> Use each page's "OnShow" handler to set button captions, if they need to 
> change e.g. to change "Next" to "Finish" on the final tab,

Thank you all, I know it is somewhat trivial looking code and it
actually is somehow.  But one has to watch the state not only for dialog
pages but each and every input field, check consistency, and so on.

Plus it's a recurring task (like reading directory entries into a
container - Delphi has a class for, lazarus not). It would have been
nice if there were a template or the like.

And there is, Luiz made it. ;)

Have fun,
Marc

-- 
Marc Santhoff <M.Santhoff at web.de>





More information about the Lazarus mailing list