在C# winfrom项目中,使用SendMessage使“CBox 央视影音”实现双击全屏,但是没有效果,无法实现双击全屏;
代码如下,帮忙看看如何修改下。
[DllImport(“user32.dll”, EntryPoint = “FindWindow”, SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport(“user32.dll”, EntryPoint = “FindWindowEx”, SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport(“user32.dll”, EntryPoint = “SendMessage”, SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, uint wMsg, int wParam, int lParam);
[DllImport(“user32.dll”)]
public static extern bool PostMessage(IntPtr hwnd, uint msg, int wParam, int lParam);
[DllImport(“user32.dll”, EntryPoint = “SetForegroundWindow”, SetLastError = true)]
private static extern void SetForegroundWindow(IntPtr hwnd);
private void button2_Click(object sender, EventArgs e)
{
const uint BM_DBCLICK = 0x0203;
IntPtr hwndCalc = FindWindow(null, “CBox 央视影音”);
if (hwndCalc != IntPtr.Zero)
{
SetForegroundWindow(hwndCalc);
System.Threading.Thread.Sleep(2000);
SendMessage(hwndCalc, BM_DBCLICK, 0, 0);
System.Threading.Thread.Sleep(2000);
}
}