Delphi跑马灯进度条

标签 delphi progress-bar

我有一个在单独线程中运行的查询,需要一段时间才能处理,因为用户当前无法知道后台正在执行某些操作,我想创建一个进度条,例如第三个进度条此图片:

enter image description here

我查看了其他问题/答案,看起来选框进度条就是我想要的,我尝试将进度条设置为选框,但它没有执行任何操作。进度条属性如下:

MarqueeInterval = 10
Max = 100
Min = 50
Orientation = pbHorizontal
Position = 50
Smooth = True
State = pbsNormal
Step = 10
Style = pbstMarquee

我做错了什么或者需要改变吗?

我的启动代码如下:

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;

最佳答案

放置一个 TProgressBar 并将其 Style 属性设置为 pbstMarquee。 应该就这样了,如果不起作用,请确保:

  1. 主线程没有被阻塞(查询是否真的在另一个线程中执行,或者是否有其他原因导致主线程被阻塞?)

  2. 该项目是在启用“启用运行时主题”选项的情况下编译的(否则,pbstMarquee 将无法工作) enable runtime themes option

关于Delphi跑马灯进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57376486/

相关文章:

XML 映射器... XE2

delphi - 检查对象是否继承自泛型类

c# - 如何显示读取文件和写入数据库的进度

user-interface - 可能需要不确定时间的任务的进度条?

jquery - 垂直进度滚动条

ruby-on-rails - 使用 Ruby aws-sdk 跟踪文件到 S3 的上传进度

delphi - 启动长时间运行的后台进程并检查状态

delphi - 在Delphi中使用ShellExecuteEx在同一命令行中运行多个任务

delphi - 如何避免对Delphi应用程序的关注?

r - 如何在R中显示代码的进度?