开发者

getting a delphi app to close a dialog that popped up from a driver

开发者 https://www.devze.com 2023-01-28 10:44 出处:网络
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\" inviti

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开发者_如何学JAVA is hanging while this dialog is open, which will make it pretty difficult to execute any code to close the dialog.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号