Reputation: 444
I've got a query running in a separate thread which takes a while to process, as the users currently has no way of knowing something is being done in the background I wanted to create a progress bar like the third progress bar on this image:
I've looked at other questions/answers and it looks like a marquee progress bar is what I'm after, I've tried setting my progress bar as marquee but it doesn't do anything. The progress bar properties are as follows:
MarqueeInterval = 10
Max = 100
Min = 50
Orientation = pbHorizontal
Position = 50
Smooth = True
State = pbsNormal
Step = 10
Style = pbstMarquee
Is there something I'm doing wrong or need to change?
My startup code is as follows:
procedure TFormMain.SetupForm;
begin
// Connect to the database
ConnectToDatabase;
// Initially hide combo box
ShowHideComboBox(False);
ListViewDataType.Columns[0].Width := -1;
UsingOwnTemplate := False;
// Initial page is the welcome page
PageControl.ActivePage := TabWelcome;
end;
procedure TFormMain.ConnectToDatabase;
var
FullPath : String;
CompanyName: String;
begin
// Create the database connection
DBConnection := TFDConnection.Create(nil);
// Get the folder path
FullPath := GetCurrentDir;
DatabasePath := FullPath;
// Setup the database connection
with DBConnection do begin
DriverName := 'MSAcc';
Params.Add(Format('Database=%s', [DatabasePath]));
Params.Add('StringFormat=UNICODE');
Connected := True;
end;
end;
Upvotes: 3
Views: 4316
Reputation: 8043
Place a TProgressBar
and set its Style
property to pbstMarquee
.
It should be all, if it doesn't work, make sure that:
The main thread is not blocked (Is the query really executed in another thread or is there any other reason why the main thread could be blocked?)
The project is compiled with the "Enable runtime themes" option enabled (Otherwise, pbstMarquee
will not work)
Upvotes: 7
Reputation: 108929
Just drop a TProgressBar
on your form and use the Object Inspector to set the Style
property to pbstMarquee
. That's all!
Upvotes: 3