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

本文关键字:方法 WndProc 找不到 覆盖 IntPtr | 更新日期: 2023-09-27 17:59:39

我试图在获胜表单应用程序中覆盖此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;
        }

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

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

您的方法签名不正确,您正在重写的Form.WndProc返回void

protected virtual void WndProc(ref Message m)

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