在Delphi中设置表单的背景图像 [英] Setting up background images for forms in Delphi

查看:237
本文介绍了在Delphi中设置表单的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使我的程序加载图像并使其成为表单的背景?
我需要确切的代码。我已经看过了互联网,我发现的唯一的事情是各种调整和修复,使背景在特殊情况下按预期工作。我也尝试过一些德尔福的书,我也找不到任何地方。

How can I make my program load an image and make it the background for a form? I need the exact code for it. I've looked all over the internet and the only things I've found are various tweaks and fixes to make backgrounds work as intended in special circumstances. I've also tried some Delphi books I have and I can't find it anywhere.

推荐答案


  1. 在您的表单上放置 TImage 。确保它在后面的所有其他控件的表单上。您可以右键单击它并选择发回到菜单选项。

  1. Put a TImageon your form. Make sure it's behind all other controls on the form. You can right-click it and choose the "send to back" menu option.

加载图形。

var
  img: TBitmap;
begin
  img := TBitmap.Create;
  try
    img.LoadFromFile('S:\background.bmp');


  • 将其分配给图像控件。

  • Assign it to the image control.

        Image1.Picture := img;
    


  • 清理。

  • Clean up.

      finally
        img.Free;
      end;
    end;
    


  • 您还可以将最后三个步骤加载图形,并立即将其放在图像控件中。感谢Jon的建议。

    You can also combine the last three steps to load the graphic and put it in the image control all at once. Thanks to Jon for the suggestion.

    Image1.Picture.LoadFromFile('B:\background.bmp');
    

    另请参见:如何向Delphi窗体添加背景图像

    这篇关于在Delphi中设置表单的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆