Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with ProgressBar problem. 1

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA
The following code works - once!
If I try and repeat it I get exception Access violation at 00470FB8 in module 'MyApp.exe'
And have to restart the program to get this procedure to work again - once. Etc. etc.

It only happens if I have ProgressBar code included.

Can someone please throw some light on this?

Procedure TfrmMyForm.btnUpDateClick(Sender: TObject);
var
MyBookmark : TBookmark;
i: SmallInt;
begin
ProgressBar1.Min := 0;
ProgressBar1.Max := 100;
ProgressBar1.Step := 1;
for i := 1 to 100 do
ProgressBar1.Position := i;

with MyTable do
begin
MyBookMark := MyTable.GetBookmark;
MyTable.First;
while not MyTable.Eof do
begin

// Do Wonderful things

ProgressBar1.Stepit;

MyTable.next;
end;
ProgressBar1.Free;
MyTable.enablecontrols;
MyTable.FreeBookMark(MyBookMark) ;
end;[/color]

 
You should remove the line
Code:
ProgressBar1.Free
This destroys the progress bar so when you click on your UpDate button the second time there is no progress bar to progress!

You should not free the progress bar if you have put the progress bar on your form at design time. The form as the owner of the progress bar will destroy it in its own destructor when the form is closed.

Andrew
Hampshire, UK
 
Thanks a million Andrew!

That works fine - except that after the final "progression" I am left with the remnant - at the point where it stopped.

But I have overcome that by controlling ProgressBar.Visible property. (Set to True at the beginning and False at the end.)

Whilst on the subject of progress bars ...

1.
How does one control the progression so that it only shows once? Finishing
the progression at the end of one progression? Instead of repeatedly.

2.
Is it possible to have the scroll bar to move vertically downwards - instead of upwards?
If so how? I donlt see a Property which allows for this.

 
Please start a new thread for a new problem.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top