我想用C#开发WinCE的程序,找了半天没有找到怎么在按钮上放图片,听说是没有带这样的控件, 都是第三方的才行.
哪位有发给小弟一个.
------解决方案--------------------
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace wince
{
class ImageButton : Control
{
//Private members
private Image image;
//flag to indicate the pressed state
private bool bPushed;
private Bitmap m_bmpOffscreen;
public ImageButton()
{
bPushed = false;
//default minimal size
this.Size = new Size(21, 21);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//Do nothing
}
public Image Image
{
get
{
return image;
}
set
{
image = value;
}
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Graphics gxOff; //Offscreen graphics
Rectangle imgRect; //image rectangle
Brush backBrush; //brush for filling a backcolor
if (m_bmpOffscreen == null) //Bitmap for doublebuffering
{
m_bmpOffscreen = new Bitmap(ClientSize.Width, ClientSize.Height);
}
gxOff = Graphics.FromImage(m_bmpOffscreen);
gxOff.Clear(this.BackColor);