WndProc找不到合适的方法来覆盖

时间:2014-03-10 05:55:17

标签: c# wndproc

我正在创建一个自定义用户控件,我试图在该控件中调用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修饰符有关吗?

2 个答案:

答案 0 :(得分:3)

签名是:

protected virtual void WndProc(ref Message m)

答案 1 :(得分:0)

只需为Messsage mSystem.Windows.Forms.Message)添加完整变量类型并传递byref

protected override void WndProc(ref System.Windows.Forms.Message m)