在线等待中, 先谢谢了。

解决方案 »

  1.   

    笨方法:
    新开一个线程(或用全局的cbt钩子)不停的查找弹出的对话框(用findwindow),如果对话框是你要控制的,则查找确定按钮(用findwindowex等),获得按钮句柄后,用sendmessage发送
    bm_click消息
      

  2.   

    //笨方法:
    //新开一个线程(或用全局的cbt钩子)不停的查找弹出的对话框(用findwindow),如果对话框是你要控制的,则查找确定按钮(用findwindowex等),获得按钮句柄后,用sendmessage发送bm_click消息这个不是很明白,能不能说得详细一点,我正好需要同楼主一样的功能的程序
      

  3.   

    查窗口和Sendmessage那个我会,不过我前面用定时器来查找关闭好像不行,新开线程怎么弄,全局ctb钩子又是什么意思?
      

  4.   

    WebBrowser Customization (Internet Explorer - WebBrowser)
    http://msdn.microsoft.com/workshop/browser/hosting/wbcustomization.asp
    Take Total Control of Internet Explorer with Advanced Hosting 
    http://www.microsoft.com/mind/1098/advhost/advhost.asp
    An ATL control for hosting and customization of multiple instances 
    www.codeproject.com/atl/vbmhwb.asp
    Q261003 HOWTO: Handle Script Errors as a WebBrowser Control Host 
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q261003 
    Q183235 WBCustomizer.dll Implements IDocHostUIHandler for VB 
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q183235
      

  5.   

    看jiangsheng(蒋晟.Net[MVP]) 给的链接,这个是正规的方法
    //新开线程怎么弄,全局ctb钩子又是什么意思?
    其实不建议这样做,vb中很难安全的实现多线程,而全局cbt钩子又需要用vc做一个额外的dll,
    参考:
    http://www.china-askpro.com/msg2/qa20.shtml
    http://www.zahui.com/html/3/6315.htm
      

  6.   

    jiangsheng(蒋晟.Net[MVP]) 给的链接看得不是很明白
    WBCustomizer.dll 我用了,但好像是禁用快捷键及浏览器菜单之类的,不能屏蔽弹出式窗口,而现在我是想屏蔽网页中用alert弹出的确定对话框(类名和msgbox弹出的对话框一样)
      

  7.   

    阿门,Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
        pDisp.Document.parentWindow.execScript "window.alert=null;"
    End Sub
      

  8.   

    supergreenbean(超级绿豆(MS MVP - VB) - 春天,什么都发~了) 的方法可以用!!
      

  9.   

    from WebBrowser Customization (Internet Explorer - WebBrowser)IDocHostShowUI
    This interface gives you control over the message boxes and help files displayed by the WebBrowser Control. It works the same way as IDocHostUIHandler and IDocHostUIHandler2 in that you implement it so the WebBrowser Control can call your IDocHostShowUI methods before it displays any messages or help menus of its own. This gives you a chance to prevent the WebBrowser Control from displaying anything and enables you to display your own custom message or help instead. IDocHostShowUI has two methods, IDocHostShowUI::ShowMessage and IDocHostShowUI::ShowHelp. IDocHostShowUI::ShowMessage
    Return S_OK to disable WebBrowser Control messages. Any other return value, like S_FALSE or E_NOTIMPL, allows the WebBrowser Control to display with its message box.One nice thing you can do with this method is customize the message box captions for your application so they don't read "Microsoft Internet Explorer." You can do this by comparing the caption string in lpstrCaption with the string resource Internet Explorer uses, which is stored in Shdoclc.dll. It is identified by the symbol IDS_MESSAGE_BOX_TITLE, whose value is 2213. The following code snippet shows how you might do this.Hide ExampleHRESULT CBrowserHost::ShowMessage(HWND hwnd,
                                      LPOLESTR lpstrText,
                                      LPOLESTR lpstrCaption,
                                      DWORD dwType,
                                      LPOLESTR lpstrHelpFile,
                                      DWORD dwHelpContext,
                                      LRESULT *plResult) 
    {
        USES_CONVERSION;
        TCHAR pBuffer[50];    // resource identifier for window caption "Microsoft Internet Explorer"
        #define IDS_MESSAGE_BOX_TITLE 2213    // Load Shdoclc.dll and the IE message box title string
        HINSTANCE hinstSHDOCLC = LoadLibrary(TEXT("SHDOCLC.DLL"));    if (hinstSHDOCLC == NULL)
        {
            // Error loading module -- fail as securely as possible
            return;
        }
        LoadString(hinstSHDOCLC, IDS_MESSAGE_BOX_TITLE, pBuffer, 50);    // Compare the IE message box title string with lpstrCaption
        // If they're the same, substitute your own Caption
        if (_tcscmp(OLE2T(lpstrCaption), pBuffer) == 0)
            lpstrCaption = L"Custom Caption";    // Create your own message box and display it
        *plResult = MessageBox(OLE2T(lpstrText), OLE2T(lpstrCaption), dwType);    // Unload Shdoclc.dll and return
        FreeLibrary(hinstSHDOCLC);
        return S_OK;
    }