向 WPF 应用程序发送消息
我正在尝试向 WPF 应用程序发送消息以使其最小化,然后恢复
我正在执行的操作
//Import the SetForeground API to activate it
[DllImportAttribute("User32.dll")]
private static extern IntPtr SetForegroundWindow(int hWnd);
[DllImportAttribute("User32.dll")]
//private static extern IntPtr SendMessage(int hWnd, int Msg, bool wParam, int lParam);
private static extern IntPtr SendMessage(int hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
....
SetForegroundWindow(hWnd); //Activate it
//in here I minimize the window manually
SendMessage(hWnd, 0x0018, (UIntPtr)0, (IntPtr)0); //trying to restore
不起作用
任何想法
I am trying to send a message to a WPF application to have it Minimize and then to restore
I am doing
//Import the SetForeground API to activate it
[DllImportAttribute("User32.dll")]
private static extern IntPtr SetForegroundWindow(int hWnd);
[DllImportAttribute("User32.dll")]
//private static extern IntPtr SendMessage(int hWnd, int Msg, bool wParam, int lParam);
private static extern IntPtr SendMessage(int hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
....
SetForegroundWindow(hWnd); //Activate it
//in here I minimize the window manually
SendMessage(hWnd, 0x0018, (UIntPtr)0, (IntPtr)0); //trying to restore
it does not work
Any ideas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能最好导入 ShowWindow 而不是仅导入 SendMessage:
然后您应该可以说
ShowWindow(hWnd, SW_MINIMIZE);
等。You're probably better off importing ShowWindow rather than just SendMessage:
You should then just be able to say
ShowWindow(hWnd, SW_MINIMIZE);
etc.