顶部的控件,像TPanel可以做吗?

发布于 2024-10-24 16:56:21 字数 166 浏览 7 评论 0原文

我的程序正在执行一项耗时的任务,我想在应用程序窗口的中间显示一个 TImage,但它不会停留在顶部 - 我的 VST 始终位于顶部。但是,当我使用 TPanel 时,它会保持在顶部吗?我怎样才能让我的 TImage 做到这一点?

事实上,适用于所有控件的解决方案将是非常棒的:)

谢谢!

My program is doing a time consuming task, and I would like to display a TImage in the middle of the application window, but it will not stay on top - my VST is always on top. However, when I use a TPanel, it stays on top? How can I make my TImage do that?

In fact, a solution that applies to all controls would be splendid :)

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泅渡 2024-10-31 16:56:21

您需要一个窗口控件(即带有窗口句柄的控件,或“适当的”控件)来显示消息,因为非窗口控件在窗口控件上方不可见。最简单的解决方案是将 TImage 放在 TPanel 中,并设置 Image1.Align := alClientPanel1.BorderStyle := bsNone

如果您希望在普通控件之上绘制半透明位图,您可以像我经常做的那样:

procedure TForm1.Button1Click(Sender: TObject);
var
  bm: TBitmap;
  png: TPngImage;
begin
  // The form contains a hidden TPanel (somewhere on the form)
  // with a TImage (alClient).

  // png is a PNG image with an alpha channel
  png := TPngImage.Create;
  try
    png.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\alpha.png');
    // Create bitmap of form and blend PNG on it
    bm := GetFormImage;
    try
      bm.Canvas.Draw(0, 0, png);
      Image1.Picture.Bitmap := bm;
    finally
      bm.Free;
    end;
    Panel1.Align := alClient;
    Panel1.BringToFront;
    Panel1.Show;
  finally
    png.Free;
  end;
end;

Sample result

You need a windowed control (that is, a control with a window handle, or a "proper" control) to display your message, because a non-windowed control cannot be visible above a windowed control. The easiest solution is to place the TImage in a TPanel and set Image1.Align := alClient and Panel1.BorderStyle := bsNone.

If you wish to draw a semi-transparent bitmap on top of your ordinary controls, you can do like I always do:

procedure TForm1.Button1Click(Sender: TObject);
var
  bm: TBitmap;
  png: TPngImage;
begin
  // The form contains a hidden TPanel (somewhere on the form)
  // with a TImage (alClient).

  // png is a PNG image with an alpha channel
  png := TPngImage.Create;
  try
    png.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\alpha.png');
    // Create bitmap of form and blend PNG on it
    bm := GetFormImage;
    try
      bm.Canvas.Draw(0, 0, png);
      Image1.Picture.Bitmap := bm;
    finally
      bm.Free;
    end;
    Panel1.Align := alClient;
    Panel1.BringToFront;
    Panel1.Show;
  finally
    png.Free;
  end;
end;

Sample result

淤浪 2024-10-31 16:56:21

TImage 没有与之关联的窗口,这就是它与面板之间的区别。

添加一个面板,并将图像放入面板中,即图像的父级是面板。然后,您可以通过将面板置于前面来将图像置于前面。

您是否考虑过隐藏您的 VST?

A TImage does not have a window associated with it and that's the difference between it and the panel.

Add a panel, and put the image inside the panel, i.e. the image's parent is the panel. Then you can bring the image to the front by bringing the panel to the front.

Did you think about hiding your VST?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文