我正在创建一个自定义用户控件,我试图在该控件中调用WndProc。但是,它给了我错误WndProc: no suitable method found to override.
public partial class MyControl : UserControl, ICloneable, IComparable<MyControl>
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override IntPtr WndProc(System.Windows.Forms.Message m)
{
SOME CODES
}
}
如何在我的usercontrol中覆盖此方法?它与partial
修饰符有关吗?
答案 0 :(得分:3)
签名是:
protected virtual void WndProc(ref Message m)
答案 1 :(得分:0)
只需为Messsage m
(System.Windows.Forms.Message
)添加完整变量类型并传递byref
:
protected override void WndProc(ref System.Windows.Forms.Message m)