using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Controls
{
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;
}
}
}
}
原文链接http://topic.csdn.net/u/20080915/18/8a8d5141-59a0-444d-afb8-179e805eb7a3.html其中加载的dll名称是怎么知道的,如果把RichBox换成TextBox为何不行?不要if判断直接
CreateParams prams = base.CreateParams;
prams.ExStyle |= 0x020; // transparent
prams.ClassName = "RICHEDIT50W";
为何不行?
override CreateParams
CreateParams 你得确保TxtBox里有这个方法可以让它得重写呀。