让delphi应用程序关闭从驱动程序弹出的对话框

发布于 2024-10-05 11:10:27 字数 603 浏览 5 评论 0原文

我有一个尝试打开网络摄像头的 delphi 应用程序。在 Windows 7 下失败< /a> 偶尔(这是另一个故事/问题/thread),但网络摄像头驱动程序还会弹出一个标题为“视频源”的对话框,邀请我选择一个。如果我尝试循环重复打开驱动程序并在每次出现对话框时手动关闭该对话框,我就可以继续。所以我想从我的应用程序中关闭对话框。 FindWindow (nil, 'Video Source') 找不到它。如果我使用进程资源管理器查看,该对话框将显示为属于我的应用程序。如果我从 PE 强制关闭它,它会关闭我的应用程序!如何关闭该对话框?我怀疑(已确认)我的应用程序在该对话框打开时挂起,这将使执行任何代码来关闭该对话框变得非常困难。

I have a delphi app that tries to open a webcam. Under Windows 7 it fails occasionally (that's another story/question/thread) but the webcam driver also pops up a dialog titled "Video Source" inviting me to select one. If I try to open the driver repeatedly in a loop and close the dialog manually each time it appears, I can get going. So I would like to close the dialog from my app. A FindWindow (nil, 'Video Source') doesn't find it. If I look with process explorer the dialog is shown as belonging to my app. If I force close it from PE it closes my app!. How to I close this dialog? I have a suspicion (confirmed) that my app is hanging while this dialog is open, which will make it pretty difficult to execute any code to close the dialog.

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

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

发布评论

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

评论(1

像极了他 2024-10-12 11:10:27

如果您的主应用程序线程由于此弹出对话框而停止等待用户输入,那么唯一的解决方案是运行另一个线程,定期尝试找到此弹出窗口。当它找到它时,然后使用 PostMessage 来使用 WM_CLOSE 或类似于弹出句柄。您可能必须将 mousedown/mouseup 消息发送到弹出窗口上的按钮。

此外,我将编写一个小型调试应用程序,它使用 Windows API WindowFromPoint 来查找弹出窗口,即。它不仅是可见的标题,而且是类别。您还可以使用此调试程序使 FindWindow 正常工作。

If your main application thread is stalled waiting for a user input due to this popup dialog then the only solution is to have another thread running which regularly attempts to locate this popup. When it does find it then use PostMessage to uses a WM_CLOSE or similar to the popup handle. You might have to send either mousedown/mouseup messages to the button on the popup.

Further, I would write a small debug application that uses the Windows API WindowFromPoint to find out about the popup window, ie. not just it's visible caption but also it's class. You can also use this debug program to get the FindWindow to work correctly.

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