Search code examples
c#wndproc

IntPtr WndProc no suitable method found to override c#


i was trying to override this WndProc in my win form application but got error IntPtr WndProc no suitable method found to override. my code as follows

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;
        }

anyone can guide me what i am missing. thanks


Solution

  • Your method signature is incorrect, Form.WndProc you are overriding returns void.

    protected virtual void WndProc(ref Message m)

    I don't know where you got that code, port from C++ maybe? but it won't work with a WinForms form.