【问题标题】:How make a firemonkey HUD window如何制作firemonkey HUD窗口
【发布时间】:2012-02-20 17:38:18
【问题描述】:

我想用 firemonkey 在 Delphi 中复制 https://github.com/jdg/MBProgressHUD 的 HUD 功能。

这是 iPhone 中的样子:

主要问题是如何使表单半透明并完全去除边框。

【问题讨论】:

  • 请编辑您的问题,并在此处发布您要执行的操作的屏幕截图或图像,而不是仅使用外部链接。如果外部链接因某种原因消失或不可用,这会使您的问题在未来对其他人毫无意义。谢谢。 :)
  • 您不能将表单设为半透明,但可以将其设为完全透明并在其上使用半透明(不透明度

标签: delphi delphi-xe firemonkey hud


【解决方案1】:

创建您的 Firemonkey HD 表单,将其设置为 Fill.Kind 至 bkNone,并将其设置为 Fill.Color 至 Null。此外,将其Transparency 属性设置为True,将BorderStyle 设置为bsNone。

创建一个 TRectangle(或任何形状),并将 Stroke.Kind 属性设置为 bkNone。将Fill.Color 设置为Gray,将Opacity 设置为0.5。

创建一个TAniIndicator 和TLabel,两者的父级作为表单。 Opacity 保持在 1.0。或者,还可以创建一个TImage 并使其大小和位置与TAniIndicator 完全相同。

从那里开始,当您想要更改图像(为勾号等)和标签文本以简单地更改为您想要显示的任何消息时,只需在 TAniIndicator 上使用TFloatAnimation 即可。理想情况下,您只需创建一个接受字符串或整数作为变量的过程,然后修改文本和指示器/图像以匹配它。例如;

Procedure TForm1.Process(Mode : Integer);
Begin
 if Mode = 1 then
 begin
  AniIndicator1.Enabled := True;
  AniIndicator1.Visible := True;
  Image1.Visible := False;
  Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
  Label1.Text := 'Loading';
 End
 else if Mode = 2 then
 Begin
  AniIndicator1.Enabled := False;
  AniIndicator1.Visible := False;
  Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
  Image1.Bitmap.LoadFromFile('Tick.png');
  Image1.Visible := True;
  Label1.Text := 'Complete!';
 end;
end;

然后您可以在主窗体中创建一个 tpanel,然后将上述窗体(包含 TAniIndicator, label, and rectangle)添加为子组件。然后,您使用有效的模式变量调用您创建的过程,它将按照您在代码中的指示运行。添加更多模式很容易,我在自己的一个应用程序中做了类似的事情(尽管它与TRectangle 相关,而不是创建指标)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-25
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多