Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Just realise that I'm about as thick as they come!

1 view
Skip to first unread message

Genome

unread,
Feb 2, 2005, 11:18:05 PM2/2/05
to
I want to write a thing called TestXYZ.

It comes up with a form that has a 'begin' button on it.

I'm not trying to be fancy here.

When you click on the 'begin' button the form turns into TestXYZ.1 with some
bits and pieces on it.

(An instruction panel and a picture thing to demonstrate what to do. With
some edit boxes that display values, and perhaps an up/down thing that lets
the user see what's going on. A done button and a 'next' button.)

When you click on the 'next' button (I might call it TestXYZ1Done) the form
turns into TestXYZ.2 with some different bits and pieces on it.

(An instruction panel and a picture thing to demonstrate what to do. With
some edit boxes that display values, and perhaps a left/right thing that
lets the user see what's going on. A couple of extra edit boxes for the user
to put some values back in along with a done button and a 'next' button.)

When you click on the 'next' button (I might call it TestXYZ2Done) the form
turns into TestXYZ.3 with some even more different bits and pieces on it.

And so on.

Now, there's probably some extra bit of underlying recording results to
files and some such stuff but, I'll try to beat me bollocks over that later.

I might, just, be able to do the bits in brackets.

At the moment I am messing about with MDI forms and that's getting a bit
aimless. I tend to do that. I really don't speak the language and I don't
know how to use it.

By the way, I've got Delphi4 Standard.

Please feel free to slap me about the face a bit.

Thanks

DNA


Raptor

unread,
Feb 3, 2005, 2:19:08 AM2/3/05
to

Genome <ilike...@yahoo.co.uk> wrote in message
news:1ChMd.1$Co...@newsfe1-gui.ntli.net...

I suggest you Google the web for 'delphi tutorial.' The stuff you're asking
about sounds as basic as you can get, not much more than the traditional
'Hello, world' programs, and you should be willing to look that up on your
own.

If you get stuck on a particular and are unable to get past it, a specific
question might get a response, but you should begin with the tutorials.

Raptor


Jeremy Collins

unread,
Feb 3, 2005, 3:01:45 AM2/3/05
to
Genome wrote:

[...]


> When you click on the 'next' button (I might call it TestXYZ1Done) the form
> turns into TestXYZ.2 with some different bits and pieces on it.
>
> (An instruction panel and a picture thing to demonstrate what to do. With
> some edit boxes that display values, and perhaps a left/right thing that
> lets the user see what's going on. A couple of extra edit boxes for the user
> to put some values back in along with a done button and a 'next' button.)
>
> When you click on the 'next' button (I might call it TestXYZ2Done) the form
> turns into TestXYZ.3 with some even more different bits and pieces on it.

Sounds like you're creating a "wizard" - a series of "windows" in a
logical order with navigation buttons.

You can accomplish this with forms, but I wouldn't recommend this
approach to a beginner, since you'll have to handle a lot of stuff
around creating forms dynamically, or showing and hiding them. Basically
you'll have a load of form-shaped juggling balls in the air ;)

The easiest way to create a wizard is with a TPageControl. You drop
one on a form, right click and "Add Page" until you've got enough, and
add controls to the various pages. It's on the Win32 tab in D4.

First you hide the tabs at runtime, in the form's OnCreate event:

procedure TForm1.FormCreate(Sender: TObject);
var
i : integer;
begin
for i := 0 to PageControl1.PageCount - 1 do
PageControl1.Pages[i].TabVisible := False;

// display first page
PageControl1.ActivePage := TabSheet1;
PageControl1Change(Sender);
end;

Now drop two buttons on the form, and call them "NextButton" (caption
"Next") and "BackButton" (caption "Back"). The OnClick events for these
would be something like this:

procedure TForm1.BackButtonClick(Sender: TObject);
var
Index : integer;
begin
Index := PageControl1.ActivePage.PageIndex;

PageControl1.ActivePage := PageControl1.Pages[Index - 1];
PageControl1Change(Sender);
end;

procedure TForm1.NextButtonClick(Sender: TObject);
var
Index : integer;
begin
Index := PageControl1.ActivePage.PageIndex;

PageControl1.ActivePage := PageControl1.Pages[Index + 1];
PageControl1Change(Sender);
end;

Finally, add an event handler for the PageControl's OnChange
event, so we can enable the buttons as needed:

procedure TForm1.PageControl1Change(Sender: TObject);
var
Index : integer;
begin
Index := PageControl1.ActivePage.PageIndex;

BackButton.Enabled := Index > 0;
NextButton.Enabled := Index < (PageControl1.PageCount - 1);
end;

HTH

--
jc

Remove the -not from email

Jamie

unread,
Feb 3, 2005, 12:59:25 PM2/3/05
to
and what was the question ?

Genome

unread,
Feb 3, 2005, 10:27:06 AM2/3/05
to

"Raptor" <bo...@none.com> wrote in message
news:ctsjc...@news2.newsguy.com...

>
> Genome <ilike...@yahoo.co.uk> wrote in message
> news:1ChMd.1$Co...@newsfe1-gui.ntli.net...
> > I want to write a thing called TestXYZ.
> > Please feel free to slap me about the face a bit.
>
> I suggest you Google the web for 'delphi tutorial.' The stuff you're
> asking about sounds as basic as you can get, not much more than the
> traditional 'Hello, world' programs, and you should be willing to
> look that up on your own.
>
> If you get stuck on a particular and are unable to get past it, a
> specific question might get a response, but you should begin with the
> tutorials.
>
> Raptor
>
>

Thanks for the reply and advice, I sort of deserve that one.

DNA


Genome

unread,
Feb 3, 2005, 10:29:59 AM2/3/05
to

"Jeremy Collins" <jd.co...@ntlworld-not.com> wrote in message
news:JTkMd.605$SC2...@newsfe1-win.ntli.net...

Absolutely brilliant! Thank you very much.

DNA

Genome

unread,
Feb 7, 2005, 1:32:55 PM2/7/05
to

"Genome" <ilike...@yahoo.co.uk> wrote in message
news:XrrMd.159$Zm6...@newsfe3-gui.ntli.net...

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
Back: TButton;
Next: TButton;
Start: TButton;
GroupBox1: TGroupBox;
Memo1: TMemo;
GroupBox2: TGroupBox;
Memo2: TMemo;
procedure FormCreate(Sender: TObject);
procedure BackClick(Sender: TObject);
procedure NextClick(Sender: TObject);
procedure StartClick(Sender: TObject);
Procedure Initialise;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);

begin
Initialise;
end;

procedure TForm1.BackClick(Sender: TObject);


var
Index : integer;
begin
Index := PageControl1.ActivePage.PageIndex;

If Index > 0 then


PageControl1.ActivePage := PageControl1.Pages[Index - 1]

else
Initialise;
end;

procedure TForm1.NextClick(Sender: TObject);


var
Index : integer;
begin
Index := PageControl1.ActivePage.PageIndex;

If Index < 4 then


PageControl1.ActivePage := PageControl1.Pages[Index + 1]

else
Initialise;
end;

procedure TForm1.StartClick(Sender: TObject);
begin
GroupBox1.Visible := False;
GroupBox2.Visible := False;
PageControl1.Visible := True;
Start.Visible := False;
Back.Visible := True;
Next.Visible := True;
end;

procedure TForm1.Initialise;
begin
PageControl1.ActivePage := TabSheet1;
PageControl1.Visible := False;
Back.Visible := False;
Next.Visible := False;
Start.Visible := True;
GroupBox1.Visible := True;
GroupBox2.Visible := True;
Memo1.Lines.LoadFromFile('shit.txt');
Memo2.Lines.LoadFromFile('shit.txt');
end;

end.

OK...... so it's looking rather crap. Just to sort of say I have looked at
your advice and done a bit with it, maybe..... sort of.

Thanks again.

DNA


Jeremy Collins

unread,
Feb 8, 2005, 3:29:13 AM2/8/05
to
Genome wrote:

> procedure TForm1.FormCreate(Sender: TObject);
>
> begin
> Initialise;
> end;

>

> procedure TForm1.NextClick(Sender: TObject);
> var
> Index : integer;
> begin
> Index := PageControl1.ActivePage.PageIndex;
> If Index < 4 then
> PageControl1.ActivePage := PageControl1.Pages[Index + 1]
> else
> Initialise;
> end;

I personally wouldn't hard-code "4" here. If you use PageCount, then
you don't have to worry about the code breaking if / when you add or
remove pages.

> procedure TForm1.StartClick(Sender: TObject);
> begin
> GroupBox1.Visible := False;
> GroupBox2.Visible := False;
> PageControl1.Visible := True;
> Start.Visible := False;
> Back.Visible := True;
> Next.Visible := True;
> end;
>
> procedure TForm1.Initialise;
> begin
> PageControl1.ActivePage := TabSheet1;
> PageControl1.Visible := False;
> Back.Visible := False;
> Next.Visible := False;
> Start.Visible := True;
> GroupBox1.Visible := True;
> GroupBox2.Visible := True;
> Memo1.Lines.LoadFromFile('shit.txt');
> Memo2.Lines.LoadFromFile('shit.txt');
> end;

OK, why is this called "initialise" if it's called many times? The word
implies "a bunch of stuff executed once to get things going".

Also, this logically doesn't work if you call it from each button
press. For one thing it resets the active page, so the user cannot
proceed through the wizard. You're also repeating a lot of things
that only need to be done once, by the look of it.

0 new messages