110,502
社区成员
发帖
与我相关
我的任务
分享
private void Form1_Load(object sender, EventArgs e)//这里写这些 对不对呀?肿么感觉效果不明显啊
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
}
protected override void OnPaint(PaintEventArgs e)
{
Rectangle rect = e.ClipRectangle;
Bitmap bufferimage = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(bufferimage);
//这中间是不是少了什么东西?那个显示在显示器上的怎么让它先绘制到bufferimage里面啊?
this.CreateGraphics().DrawImage(bufferimage, 0, 0);
}
namespace Boundary032201
{
public class cilpButton : Button //这个是我照这你写的这个套上来的
{ //这个按钮类是不是这样直接创建的?
public cilpButton()
{
InitializeComponent();
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |ControlStyles.UserPaint |ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
}
private IContainer components;
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//我是在这里初始化 按钮上面的图片的,像下面这样
btn_stop.Image = bmpNormal;
btn_start.Image = bmpNormal;
}
//切换按钮图片是 在Click事件中 切换的
}
//这样写是不是有问题啊?
Bitmap bmp = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmp);
g.DrawString("sssss", this.Font, Brushes.Red,10,10);
this.BackgroundImage = bmp;