Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi4 - progress bar usage

Posted on 2007-04-09
4
Medium Priority
?
210 Views
Last Modified: 2010-04-05
Hi

I am using a progressbar while loading treeview from paradox table.
but my problem is that the progress of the bar is not moving with the load operation.meaning that it finishes loading the bar and then loading the tree.
My code is :
try
with progressbar1 do begin
stepit;
BuildTree; // i am callling procedure to load the tree from the table
finally
free
end

so how can i make it move together so when the progress of the bar finishes i will load the tree immidealty not wait for more time and the bar is at the max position

thanks a lot
0
Comment
Question by:ibrobar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
xr1140 earned 150 total points
ID: 18875005

1. query the number of record you have to load from the DB

2. set the progressbar max property to that value

3. as soon as each node is loaded, update your progressbar position
0
 
LVL 5

Expert Comment

by:xr1140
ID: 18875013
i almost forgot ... insert an Application.ProcessMessages; in your loop to allow your form to respond to paint message.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 18875317
var
   i, loopVal: integer;
begin
   try
      // open the query
      ADOQuery1.Open;
      // turn off treeview update
      TreeView1.Items.BeginUpdate;
      try
         // get max loop value and max progress bar position
         loopVal := ADOQuery1.RecordCount;
         // set the max of the progress bar
         ProgressBar1.Max := loopVal;
         for i := 1 to loopVal do
         begin
            // add treenode

            // update progress bar
            ProgressBar1.Position := i;
            // let the system catch up
            Application.ProcessMessages;
         end;
      finally
         // turn on treeview
         TreeView1.Items.EndUpdate;
      end;
   except
      // handle exception

   end;
end;
0
 

Author Comment

by:ibrobar
ID: 18897834
Hi All

Sorry for the delay , I will get back to you in couple of days

regards
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question