引用文本框添加背景图片,背景透明,文字渲染:
public class DataGridView背景 : DataGridView
{
protected override void PaintBackground(Graphics 绘图画面, Rectangle 绘制背景, Rectangle 绘制区域)
{
string[] 景图 = "葫芦.ico,葫芦1.ico,葫芦3.ico,葫芦4.ico,葫芦5.ico,葫芦6.ico,葫芦7.ico,葫芦8.ico,葫芦10.ico".Split(',');
base.PaintBackground(绘图画面, 绘制背景, 绘制区域);
绘图画面.DrawImage(new Bitmap(@System.Environment.CurrentDirectory + "\\ICO\\" + 景图[DateTime.Now.Minute % 9]), 绘制区域);
Rectangle 区域 = new Rectangle(绘制区域.X + 1, 绘制区域.Y + 1, 绘制区域.Width - 3, 绘制区域.Height - 3);
绘图画面.DrawRectangle(Pens.Red, 区域);
}
}
public class TextBox透明 : TextBox
{
[System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern IntPtr LoadLibrary(string 文件名);
protected override CreateParams CreateParams
{
get
{
CreateParams 控件句柄 = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
控件句柄.ExStyle |= 0x020; // transparent 当背景透明后文本框中的原有快捷菜单就不可用了.RichTextBox
控件句柄.ClassName = "RICHEDIT50W";
}
return 控件句柄;
}
}
}
public class TextBox背景 : TextBox
{
const int WM_ERASEBKGND = 0x0014;
private Image 背景图片;
string[] 景图