Windows C++将启动的子进程带到前台
我正在通过 CreateProcess API 启动一个子进程。但是,由于启动并显示其主窗口需要一些时间,因此用户可能会在发生这种情况时单击父窗口中的其他位置。然后子窗口转到背景。我如何将其从父进程返回到前台?
I am launching a child process via CreateProcess API. However, because it takes some time to start up and show its main window, its possible for the user to click elsewhere in the parent window while this is happening. The child window then goes to the background. How would I get it back into the foreground from the parent process?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你不知道,用户认为她厌倦了等待,想要使用响应式程序。查看 SetForegroundWindow() 中的细则,了解尝试找到解决方法实际上行不通的所有原因。确保她可以在程序初始化时返回到程序,任务栏按钮是关键。
You don't, the user decided that she was tired of waiting and wanted to work with a responsive program. Review the fine print in SetForegroundWindow() for all the reasons that trying to find a workaround for this won't actually work. Make sure she can get back to the program when it is initialized, a taskbar button is key.
我过去曾使用 SetWindowPos() 来实现此目的。它就像一把瑞士军刀,它可以移动窗口并调整窗口大小,还可以更改它们的 z 顺序位置。您只需将其 z 顺序更改为 HWND_TOP。
I've used SetWindowPos() for this in the past. It's kind of a swiss army knife, it can move and resize windows, as well as change their z-order position. You just want to change its z-order to HWND_TOP.
SetActiveWindow()
过去也对我有用,我推荐它。SetActiveWindow()
also worked for me in the past, I recommend it.