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

时间:2014-04-23 11:28:11

标签: c# wndproc

我试图在我的win表单应用程序中覆盖此WndProc,但收到错误IntPtr WndProc no suitable method found to override。我的代码如下

protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == NativeCalls.APIAttach && (uint)lParam == NativeCalls.SKYPECONTROLAPI_ATTACH_SUCCESS)
            {
                // Get the current handle to the Skype window
                NativeCalls.HWND_BROADCAST = wParam;
                handled = true;
                return new IntPtr(1);
            }
            // Skype sends our program messages using WM_COPYDATA. the data is in lParam
            if (msg == NativeCalls.WM_COPYDATA && wParam == NativeCalls.HWND_BROADCAST)
            {
                COPYDATASTRUCT data = (COPYDATASTRUCT)Marshal.PtrToStructure(lParam, typeof(COPYDATASTRUCT));
                StatusTextBox.Items.Add(data.lpData + Environment.NewLine);
                // Check for connection
                //if (data.lpData.IndexOf("CONNSTATUS ONLINE") > -1)
                  //  ConnectButton.IsEnabled = false;
                // Check for calls
                IsCallInProgress(data.lpData);
                handled = true;
                return new IntPtr(1);
            }

            return IntPtr.Zero;
        }

任何人都可以指导我缺少的东西。感谢

1 个答案:

答案 0 :(得分:1)

您的方法签名不正确,Form.WndProc您将覆盖返回void

protected virtual void WndProc(ref Message m)

我不知道你从哪里得到那些代码,也许来自C ++的端口?但它不适用于WinForms表单。