WPF如何处理Windows消息
发送消息到指定窗口 发送消息相对来说比较简单,这里先讲,这里需要用到两个Windows的API csharp ▼ 1 2 3 4 5 6 7 8 9 10 11 12 // 查找指定窗口 [DllImport("User32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); //消息发送API [DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] public static extern int SendMessage( IntPtr hWnd, // 信息发往的窗口的句柄 int Msg, // 消息ID IntPtr wParam, // 参数1 IntPtr lParam // 参数2 ); FindWindow就是根据窗口的名字去找到相应的窗口句柄,SendMessage就是发送消息到指定窗口了,写过MFC的应该不陌生 ...