c# form窗体添加背景图片,代码怎么写

c# form窗体添加背景图片,代码怎么写,第1张

有两种方法,方法一:

1、this.BackgroundImage = Image.FromFile(@"图片路径")

2、this.BackgroundImage = this.imageList1.Images[0]

方法二:

imageList设置图片像素只能是在1-256

C# 窗体背景图片怎么跟随窗体变化而变化

背景图单独存放在其它位置后,当窗口的OnResize事件发生时,

对图片缩放后,作为背景。根据此原理,实现如下:

这里借用了一个pictureBox.不改变它的其它属性,如改变Image属性后,编写如下代码

private void Form2_SizeChanged(object sender, System.EventArgs e){loadBackImage()}

private void loadBackImage(){Bitmap bit = new Bitmap(this.Width,this.Height)

Graphics g =  Graphics.FromImage(bit)

g.DrawImage(this.pictureBox1.Image,newRectangle(0,0,bit.Width,bit.Height),0,0,this.pictureBox1.Image.Width,this.pictureBox1.Image.Height,GraphicsUnit.Pixel)

this.BackgroundImage = bit

g.Dispose()}private void Form2_Load(object sender, System.EventArgs e)loadBackImage()}

现在Windows Form直接支持用flash来做界面, 你把动画在flash中实现就可以了。这样做出来的动画内容更丰富。

默认情况是不支持的,你得在工具栏中添加,具体方法见下面:

http://stackoverflow.com/questions/1037/displaying-flash-content-in-a-c-winforms-application

我自己都已经用过了,能行。还有一种情况如果用的是64位 *** 作系统会出问题,flash对64位支持不到位。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11425197.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-16
下一篇2023-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存