This component allows you to create forms of wait with progress bar (optional) in a simple way using threads. The use of the thread causes the application not to be locked during the execution of a process.
[Optional]
For ease I recommend using the Boss for installation- Boss - Dependency Manager for Delphi
- BlockUI-VCL - Block User Interface for VCL Projects (Delphi)
boss install github.com/viniciussanchez/wait-vcl
Add the following folders to your project, in Project > Options > Resource Compiler > Directories and Conditionals > Include file search path
../wait-vcl/src
../wait-vcl/src/view
../wait-vcl/src/providers
You need to use VCL.Wait
uses VCL.Wait;
var
Waiting: TWait;
begin
Waiting := TWait.Create('Wait...');
Waiting.Start(
procedure
var
I: Integer;
begin
Waiting.ProgressBar.SetMax(100);
for I := 1 to 100 do
begin
Waiting.SetContent('Wait... ' + I.ToString + ' of 100').ProgressBar.Step();
Sleep(100); // Your code here!!!
end;
end);
end;
You can increment more than one:
Waiting.ProgressBar.Step(2);
The Start function will create a thread to execute the procedure passed as parameter. Within a thread should not be made interactions with the user! If you need to, use a TThread.Synchronize.
begin
TWait.Create('Wait...').Start(
procedure
begin
Sleep(1500); // Your code here!!!
end);
end;