我试图在我的胜利表单应用中覆盖此WndProc
,但得到错误IntPtr WndProc no suitable method found to override
。我的代码如下IntPtr WndProc找不到合适的方法来覆盖c#
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;
}
任何人都可以指导我,我错过了什么。谢谢
您正在混淆您的类库。这是HwndHost.WndProc()方法的重写,仅用于WPF应用程序。 Winforms使用* Message *结构。只要让IntelliSense自动完成你的覆盖,不能搞乱它。 –
可能重复[如何在Windows窗体应用程序中使用此WndProc?](http://stackoverflow.com/questions/23220111/how-to-use-this-wndproc-in-windows-forms-application) – LarsTech