如何从另一个应用程序销毁MODAL对话框窗口 [英] How To Destroy a MODAL Dialog Box Window From Another Application

查看:54
本文介绍了如何从另一个应用程序销毁MODAL对话框窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用DestroyWindow远程销毁密码提示对话框,每次我远程打开特定的PDF文档时,该对话框都会弹出. (不起作用!)

在此之前,我还尝试使用WM_CLOSE值的SendMessage,如下所示:


I tried using DestroyWindow to remotely destroy a password prompt dialog box that keeps popping-up every time I remotely open a particular PDF document. (It doesn''t work!)

Before this I was also trying SendMessage with the WM_CLOSE value as shown below:


Public Const WM_CLOSE = &H10

Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
         ByVal wParam As IntPtr, ByRef lParam As IntPtr) As IntPtr

    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
        ByVal wParam As Integer, ByRef lParam As IntPtr) As Integer

    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
        ByVal wParam As Integer, ByRef lParam As Integer) As Integer

    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
        ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr

Dim dialog_title As String = "Password"
Dim hwnd As IntPtr = FindWindow(vbNullString, dialog_title)
SendMessage(hwnd, WM_CLOSE, 0, 0)




当我这样做时,几乎什么也没有发生(什么也没有发生).
仔细观察后,我确实注意到光标在密码输入字段中闪烁了大约半秒钟,然后又开始闪烁了.仅此而已.

也许我没有正确使用SendMessage函数;我不知道.我尝试了很多方法.

任何人都可以看到我的代码出了什么问题,或者建议一种确保成功"的方法来摆脱模态对话框.

谢谢.




When I do this virtually nothing happens (nothing ever happens).
Upon keen observation I did notice that the cursor blinking in the password input field went off for about half-a-second then started blinking again; that''s all.

Maybe I''m not using the SendMessage function right; I dunno. I''ve tried so many ways.

Can anyone see whats wrong with my code or suggest a "sure-fire" way that might work to get rid of the modal dialog.

Thanks.

推荐答案

我查看了您的解决方案,而这正是我所尝试的.您有两个问题:

1.您是否使用调试器查看了hwnd的值?您应该确保它是正确的窗口.

2.如果在Vista或更高版本上,您是否尝试过以管理员身份运行此程序?
I looked at your solution and that''s exactly what I would have tried. Two questions for you:

1. Have you used the debugger to look at the value of hwnd? You should make sure it''s the right window.

2. If on Vista or later, have you tried running this program as an admin?


问题-父应用是否由于未输入密码而立即重新创建对话框?
Question - is the parent app recreating the dialog right away because no password was entered ?


克里斯蒂安·格劳斯(Christian Graus)说:

Christian Graus says:

问题-父应用是否由于未输入密码而立即重新创建对话框?
Question - is the parent app recreating the dialog right away because no password was entered ?




否.当我手动单击密码对话框上的任何按钮时,除确定"按钮外,它都将关闭并且从不会再出现,除非重新打开文档.




No. When I manually click any button on the password dialog, apart from the OK button, it closes and never re-appears unless the document is re-opened.


这篇关于如何从另一个应用程序销毁MODAL对话框窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆