一种简单的方式来显示TTabSheet选项卡上的活动 [英] A simple way to show activity on the tab for a TTabSheet
问题描述
基本上,我想要一个活动指示器,一目了然地显示该选项卡上正在进行的活动计算。我正在寻找一个非常简单的东西,就像在标签上显示一个gif,或者显示一个用定时器改变的字符串序列。我不想要一个复杂的解决方案或需要新组件的解决方案。
Basically I want an activity indicator that will show at a glance that there is an active calculation in progress on that tab. I'm looking for something very simple, like showing a gif on the tab, or showing a sequence of strings that change with a timer. I don't want a complicated solution or a solution that requires new components.
我已经有一个实现,但我有一个问题,我是要求一个更具体的解决方案到这里:如何在日语中显示反斜杠区域设置
I already have an implementation, but I'm having a problem with it that I'm asking for a more specific solution to here: How to show backslash in a japanese locale
如果没有解决其他问题,或者有一个更好的方法来做到这一点,我问更一般的问题。在任何情况下,我确信会有其他人可以使用一个很好的方法来做到这一点。
In the case that there isn't a solution to the other problem, or that there is a significantly better way to do this, I am asking the more general question. In any case, I'm sure that there will be others that could use a good way to do this.
推荐答案
更新:
最简单的方法可能是:
- 添加一个
TImageList
到您的表单。 - 将动画图像添加到图像列表。
- 设置常量
cMaxImageIndex
到动画列表的最后一个索引。 - 将ImageList连接到
TPageControl
。 - 声明函数
NextImageIndex
。 - 适当时激活定时器。 li>
- 在计时器事件中,设置标签页
ImageIndex
属性。
- Add an
TImageList
to your form. - Add your animation images to the image list.
- Set the constant
cMaxImageIndex
to the last index of the animated list. - Connect the ImageList to the
TPageControl
. - Declare a function
NextImageIndex
. - Activate the timer when appropriate.
- In the timer event, set the tabsheet
ImageIndex
property.
查看代码:
Const
cMaxImageIndex = 5;
procedure TForm1.FormCreate(Sender: TObject);
begin
FImageIndex := 0;
end;
function TForm1.NextImageIndex: Integer;
begin
Inc(FImageIndex);
if (FImageIndex > cMaxImageIndex) then FImageIndex:= 0;
Result := FImageIndex;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
PageControl1.Pages[0].ImageIndex := NextImageIndex;
end;
注意:在激活定时器之前,设置 FIMageIndex
为零,当工作完成时,您也可能有一些逻辑来为标签设置默认图像。
Note : Before activating the timer, set FImageIndex
to zero, and when work is done you might also have some logic to have a default image for the tab.
这篇关于一种简单的方式来显示TTabSheet选项卡上的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!