引用了一个控件 但该控件没有点击事件 现在想给他添加点击事件编译正常 但是无法添加入工具箱 是那里有错误?public partial class DHControl : AxDHSURVEILLANCECTRLLib.AxDHSurveillanceCtrl //外部控件
{
public DHControl()
{
InitializeComponent();
} protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
} protected override void OnDoubleClick(EventArgs e)
{
base.OnDoubleClick(e);
} protected override void OnClick(EventArgs e)
{
base.OnClick(e);
}
}
{
public DHControl()
{
InitializeComponent();
} protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
} protected override void OnDoubleClick(EventArgs e)
{
base.OnDoubleClick(e);
} protected override void OnClick(EventArgs e)
{
base.OnClick(e);
}
}
base调用的事件是否在基类中都存在
base调用的事件是否在基类中都存在
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); X x = new X();
x.Parent = this;
} [br
public class X : Control
{
public X()
{
this.Size = new Size(100, 100);
this.BackColor = Color.Red;
} protected override void WndProc(ref Message m)
{
int WM_LBUTTONDOWN = 0x0008;
int WM_KILLFOCUS = 0x0008; if (m.Msg == WM_LBUTTONDOWN)
{
MessageBox.Show("鼠标左键单击");
m.Msg = WM_KILLFOCUS;
}
base.WndProc(ref m);
}
}
}
}编译完这个exe,重开一个项目,工具栏右键“选择项”,点浏览加入这个exe后,工具栏里就有了个X控件,当然标准的是应该继承自usercontrol,放class里编译成dll
int WM_LBUTTONDOWN = 0x0201;
其中一项是让控件支持鼠标事件
继承的控件中不包含WndProc