日期:2014-05-18 浏览次数:21771 次
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { RichEdit50 re = new RichEdit50(); //用RichEdit50来取代你的TextBox 这个就是透明文本框 re.Text = "I am Transparent"; this.Controls.Add(re); this.Show(); } } public class RichEdit50 : RichTextBox { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName); protected override CreateParams CreateParams { get { CreateParams prams = base.CreateParams; if (LoadLibrary("msftedit.dll") != IntPtr.Zero) { prams.ExStyle |= 0x020; // transparent prams.ClassName = "RICHEDIT50W"; } return prams; } } }