我試圖在我的勝利表單應用中覆蓋此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