运行静默应用程序 VC++ 时 GUI 被阻止

发布于 2024-08-22 04:48:58 字数 714 浏览 4 评论 0原文

我用 C++(Windows XP、Visual C++ 2008)构建了一个 GUI 界面。您可以在那里配置一些参数,当我单击“确定”按钮时,将启动一个静默应用程序(并使用设置的值)。当我这样做时,如果您切换到其他窗口,GUI 会冻结甚至消失(它仍然存在,但您只能看到一个空白),当其他应用程序完成时,GUI 会再次工作。

这是正确的行为,我不希望用户能够编辑字段......但是当你看不到 GUI 时,它有点难看。有谁知道一种简单的方法可以切换到其他窗口并在切换回来时能够看到 GUI?

提前致谢

编辑:

嗨,我尝试这样做,但问题是要在后台运行应用程序,我有一个使用 CreateProcess 的函数。因此,GUI 都会被冻结:如果我创建一个创建进程的线程,或者如果我直接创建进程。

然后我等待进程完成:

if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) { 返回 GetLastError();
} WaitForSingleObject(ProcessInfo.hProcess, INFINITE); if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) rc = 0;

有什么想法吗?

I have built a GUI interface in C++ (Windows XP, visual c++ 2008). There you can configure some parameters and when I click on the OK button, a silent application is launched (and uses the values setted). When I do this, the GUI frozes and even dissappears if you switch to other windows(it's still there, but you can only see a white space), when the other application's finished the GUI works again.

This is the correct behaviour, I don't want the user to be able to edit the fields... but it's a bit ugly when you can't see the GUI. Does anybody know an easy way of being able to switch to other windows and being able to see the the GUI when you switch back?

Thanks in advance

Edited:

Hi, I tried doing this, but the problem is that to run the apps in background I had a function that uses CreateProcess. So both ways the GUI gets frozen: if I create a Thread that creates the process and if I creathe the process directly.

Then I wait for the process to finish:

if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo))
{
return GetLastError();
}
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc))
rc = 0;

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

絕版丫頭 2024-08-29 04:48:58

在第二个线程中启动外部应用程序,并通过模式弹出窗口阻止主线程。在模态弹出窗口中,使用计时器定期检查第二个线程是否已完成,如果已完成则将其关闭。

作为奖励,您可以在模态弹出窗口中显示花费的时间。

Start the external application in a second thread, and block your main thread via a modal popup. In the modal popup use a timer to regularly check if the second thread has already finished and close it if it has.

As a bonus you could show the time spent in your modal popup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文