#2
yiyanxiyin2024-04-07 17:00
|
程序代码:
namespace 不允许在textBox里粘贴
{
public partial class loginForm : Form
{
public loginForm()
{
InitializeComponent();
}
private Point offset;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (MouseButtons.Left != e.Button) return;
Point cur = this.PointToScreen(e.Location);
offset = new Point(cur.X - this.Left, cur.Y - this.Top);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (MouseButtons.Left != e.Button) return;
Point cur = MousePosition;
this.Location = new Point(cur.X - offset.X, cur.Y - offset.Y);
}
private void loginForm_Load(object sender, EventArgs e)
{
}
private void btlCloseButton_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text!=""){ //要注意.Text,需要大写
};
}
}
}
{
public partial class loginForm : Form
{
public loginForm()
{
InitializeComponent();
}
private Point offset;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (MouseButtons.Left != e.Button) return;
Point cur = this.PointToScreen(e.Location);
offset = new Point(cur.X - this.Left, cur.Y - this.Top);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (MouseButtons.Left != e.Button) return;
Point cur = MousePosition;
this.Location = new Point(cur.X - offset.X, cur.Y - offset.Y);
}
private void loginForm_Load(object sender, EventArgs e)
{
}
private void btlCloseButton_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text!=""){ //要注意.Text,需要大写
};
}
}
}
我设计一个窗口,就是想让textBox屏蔽粘贴功能,在别处找了一个代码,如下:
程序代码:
class TextBoxx : TextBox
{
public const int WM_PASTE = 0x0302;//粘贴消息信息
protected override void WndProc(ref Message m)//重写处理消息方法
{
if (m.Msg != WM_PASTE)//屏蔽粘贴消息信息
{
base.WndProc(ref m);//调用基类消息处理方法
}
}
}
{
public const int WM_PASTE = 0x0302;//粘贴消息信息
protected override void WndProc(ref Message m)//重写处理消息方法
{
if (m.Msg != WM_PASTE)//屏蔽粘贴消息信息
{
base.WndProc(ref m);//调用基类消息处理方法
}
}
}
现在不知道怎么把这段代码融合进去,我那个textBox是设计时添加的,这个是运行时再产生