Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 网格进度条或动画_Delphi - Fatal编程技术网

Delphi 网格进度条或动画

Delphi 网格进度条或动画,delphi,Delphi,如何在网格单元中绘制进度条或gif动画 谢谢 以下是我用来在状态栏面板中绘制进度条的一些代码: R := Rect; R.Right := MulDiv(Width, FProgressPercent, 100); inc(R.Right, R.Left); (* We prefer to draw our inline progress bar using the prevailing theme. However, the theme API uses the w

如何在网格单元中绘制进度条或gif动画


谢谢

以下是我用来在状态栏面板中绘制进度条的一些代码:

  R := Rect;
  R.Right := MulDiv(Width, FProgressPercent, 100);
  inc(R.Right, R.Left);
  (* We prefer to draw our inline progress bar using the prevailing theme.  However, the theme API
     uses the wrong colour on XP so we only do this for Vista / Server 2008 and later. *)
  if (Win32MajorVersion>=6) and ThemeServices.ThemesEnabled then begin
    Details.Element := teProgress;
    Details.Part := PP_FILL;
    Details.State := PBFS_NORMAL;
    ThemeServices.DrawElement(Canvas.Handle, Details, R);
  end else begin
    Canvas.Brush.Color := clHighlight;
    Canvas.Brush.Style := bsSolid;
    Canvas.FillRect(R);
  end;
此代码在
OnDrawPanel
事件处理程序中运行,但您可能希望对网格使用类似于
OnDrawCell
事件的内容
Rect
是“我的代码”中状态栏面板的客户端区域,您需要整个网格单元作为代码

我还通过在上面的代码之后运行此代码,在顶部绘制百分比文本

  Text := Format('%d%%', [FProgressPercent]);
  Size := Canvas.TextExtent(Text);
  Left := Rect.Left+(Width-Size.cx) div 2;
  Top := Rect.Top+(Height-Size.cy) div 2;
  Canvas.Brush.Style := bsClear;
  Canvas.Font.Color := clHighlightText;
  Canvas.Font.Style := [fsBold];
  Canvas.TextRect(Rect, Left, Top, Text);

与您想做的不完全相同,但希望这些想法能得到贯彻。

以下是我用来在状态栏面板中绘制进度条的一些代码:

  R := Rect;
  R.Right := MulDiv(Width, FProgressPercent, 100);
  inc(R.Right, R.Left);
  (* We prefer to draw our inline progress bar using the prevailing theme.  However, the theme API
     uses the wrong colour on XP so we only do this for Vista / Server 2008 and later. *)
  if (Win32MajorVersion>=6) and ThemeServices.ThemesEnabled then begin
    Details.Element := teProgress;
    Details.Part := PP_FILL;
    Details.State := PBFS_NORMAL;
    ThemeServices.DrawElement(Canvas.Handle, Details, R);
  end else begin
    Canvas.Brush.Color := clHighlight;
    Canvas.Brush.Style := bsSolid;
    Canvas.FillRect(R);
  end;
此代码在
OnDrawPanel
事件处理程序中运行,但您可能希望对网格使用类似于
OnDrawCell
事件的内容
Rect
是“我的代码”中状态栏面板的客户端区域,您需要整个网格单元作为代码

我还通过在上面的代码之后运行此代码,在顶部绘制百分比文本

  Text := Format('%d%%', [FProgressPercent]);
  Size := Canvas.TextExtent(Text);
  Left := Rect.Left+(Width-Size.cx) div 2;
  Top := Rect.Top+(Height-Size.cy) div 2;
  Canvas.Brush.Style := bsClear;
  Canvas.Font.Color := clHighlightText;
  Canvas.Font.Style := [fsBold];
  Canvas.TextRect(Rect, Left, Top, Text);

与您想做的不完全相同,但希望这些想法能得到贯彻。

您使用的是哪种网格组件?+1 RRUZ@罗德里克,有几十个(如果不是几百个)可能的网格。仅在Delphi中,就有TStringGrid、TDBGrid和TDrawGrid。此外,您没有提供足够的信息来说明您想要做什么-进度条是否适用于单个单元格,或整个网格,或。。。???你的问题太模糊了,甚至猜不出答案。请重新措辞并提供足够的细节,使其成为一个实际问题,否则很可能会以“非真实问题”结束。您的问题分为两部分。(1) 如何在网格中自定义绘制。你可能会发现很多有趣的文章,比如这篇。如果你对ofc感兴趣,也可以自己用谷歌搜索。以及(2)如何绘制进度条。David已经发布了一个方法。请自己尝试一下这里所展示的技巧,如果您仍然有疑问,请返回一个更精确的查询。您已经成为会员将近两年了!,我想是时候读一下这篇文章,写一个详细的问题了!您正在使用哪个网格组件?+1 RRUZ@罗德里克,有几十个(如果不是几百个)可能的网格。仅在Delphi中,就有TStringGrid、TDBGrid和TDrawGrid。此外,您没有提供足够的信息来说明您想要做什么-进度条是否适用于单个单元格,或整个网格,或。。。???你的问题太模糊了,甚至猜不出答案。请重新措辞并提供足够的细节,使其成为一个实际问题,否则很可能会以“非真实问题”结束。您的问题分为两部分。(1) 如何在网格中自定义绘制。你可能会发现很多有趣的文章,比如这篇。如果你对ofc感兴趣,也可以自己用谷歌搜索。以及(2)如何绘制进度条。David已经发布了一个方法。请自己尝试一下这里所展示的技巧,如果您仍然有疑问,请返回一个更精确的查询。您已经成为会员将近两年了!,我想是时候读一下这篇文章,写一个详细的问题了+1用柠檬做柠檬水(说明性答案)(问题)+1用柠檬做柠檬水(说明性答案)(问题)