Internet explorer firefox中是否有类似gBrowser.getNotificationBox()的IE通知框

Internet explorer firefox中是否有类似gBrowser.getNotificationBox()的IE通知框,internet-explorer,bho,Internet Explorer,Bho,我目前正在编写的浏览器辅助对象需要提醒用户某些情况。 我不想使用WinAPI函数MessageBox,因为它会强制用户单击它。 是否有可能在不阻塞用户工作流程的情况下向用户提问?如果他现在对这个问题不感兴趣,他应该可以忽略这个问题。 类似于用于firefox扩展的gBrowser.getNotificationBox()的东西将是理想的选择(附示例图像) 您可以创建自己的窗口,并使用SetWindowPos将其移动到IE窗口中 如果你想稳妥起见,我建议你写封信 目前还没有一个API来定制信息栏(

我目前正在编写的浏览器辅助对象需要提醒用户某些情况。 我不想使用WinAPI函数MessageBox,因为它会强制用户单击它。 是否有可能在不阻塞用户工作流程的情况下向用户提问?如果他现在对这个问题不感兴趣,他应该可以忽略这个问题。
类似于用于firefox扩展的gBrowser.getNotificationBox()的东西将是理想的选择(附示例图像)

您可以创建自己的窗口,并使用SetWindowPos将其移动到IE窗口中

如果你想稳妥起见,我建议你写封信


目前还没有一个API来定制信息栏(又称安全带)的内容。

我终于可以解决这个问题了。下面的答案和相关的答案确实帮助了我。在那里,您还可以找到有关此问题的更多信息。 如果有人有同样的问题,这里是我的代码。我认为如果没有我的其他项目代码,它将无法编译,但它应该给出一个想法,如何在浏览器助手对象中实现这样一个对话框:

标题:

#include "atlbase.h"
#include "atlwin.h"
#include "resources/resource.h"
#include <string>

class NotificationBar : public CDialogImpl<NotificationBar>
{
public:
    NotificationBar();

    enum { IDD = IDD_NOTIFICATIONBAR };

    BEGIN_MSG_MAP(CMyDialog)
        COMMAND_HANDLER(IDC_CANCEL, BN_CLICKED, OnBnClickedCancel)
    END_MSG_MAP()

    void show(const std::string &message);

    void show();

    void fitSize();

    void hide();

    void setText(const std::string &text);

private:

    LRESULT OnBnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

    bool isShown;
};
函数webbrowser.getCurrentTabHwnd()返回当前选项卡窗口:

HWND WebBrowser::getCurrentTabHwnd()
{
    CComPtr<IServiceProvider> pServiceProvider;
    if (!SUCCEEDED(_browser->QueryInterface(IID_PPV_ARGS(&pServiceProvider))))
        throw std::exception("QueryInterface for IID_IServiceProvider failed in WebBrowser::getCurrentTabHwnd()");

    CComPtr<IOleWindow> pWindow;
    if (!SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARGS(&pWindow))))
        throw std::exception("QueryService for SID_SShellBrowser, IID_IOleWindow failed in WebBrowser::getCurrentTabHwnd()");

    HWND hwndBrowser = NULL;
    if (!SUCCEEDED(pWindow->GetWindow(&hwndBrowser)))
        throw std::exception("GetWindow failed in WebBrowser::getCurrentTabHwnd()");

    return hwndBrowser;
}
HWND WebBrowser::getCurrentTabHwnd() { 客户服务提供商; 如果(!成功(_浏览器->查询接口(IID_PPV_参数(&pServiceProvider))) 抛出std::exception(“WebBrowser::getCurrentTabHwnd()中IID_IServiceProvider的查询接口失败”); 首席采购官; 如果(!成功(pServiceProvider->QueryService(SID\u Sshell浏览器、IID\u PPV\u参数(&pWindow))) 抛出std::exception(“在WebBrowser::getCurrentTabHwnd()中为SID\u SShellBrowser、IID\u IOleWindow提供的查询服务失败”); HWND hwndBrowser=NULL; 如果(!成功(pWindow->GetWindow(&hwndBrowser))) 抛出std::exception(“WebBrowser::getCurrentTabHwnd()中的GetWindow失败”); 返回hwndBrowser; } 您还必须在每次调整浏览器窗口的大小时调用NotificationBar::fitSize()。为此,您可以在IE的DocumentComplete事件中使用IHTMLWindow3::attachEvent(_T(“onresize”),…)

以下是在DocumentComplete处理程序中获取IHTMLWindow3实例的方法:

  • IWebBrowser2::getDocument()返回IHTMLDocument2
  • IHTMLDocument2::get_parentWindow()返回IHTMLWindow2
  • IHTMLWindow2::QueryInterface(IID_IHTMLWindow3,…)成功

  • 我知道IE也有类似的功能(每当它说“Internet Explorer阻止了ActiveX[blah]”或其他什么的时候,你都会看到这个条),但我不记得它叫什么,也不记得你会如何编程使用它。浏览器栏可以通过IE菜单显示,因此不适合消息框的需要。所以我认为SetWindowPos是一种方式。是否有可能说“请使用父窗口自动调整大小”,或者在IE的OnResize事件中我必须调整子窗口的大小?我发现了一个有趣的教程()。那里的子窗口似乎是我想要的(除了在窗口底部而不是顶部的位置),但作者没有提到他是如何做到的。该窗口实际上在浏览器之外,BHO调整了浏览器的大小,为编辑窗口留出了一些空间。我认为在标签浏览时代,你不应该在BHO中这样做。现在,一个窗口可能包含许多BHO,您不希望每次用户打开选项卡时都调整浏览器的大小。
    HWND WebBrowser::getCurrentTabHwnd()
    {
        CComPtr<IServiceProvider> pServiceProvider;
        if (!SUCCEEDED(_browser->QueryInterface(IID_PPV_ARGS(&pServiceProvider))))
            throw std::exception("QueryInterface for IID_IServiceProvider failed in WebBrowser::getCurrentTabHwnd()");
    
        CComPtr<IOleWindow> pWindow;
        if (!SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARGS(&pWindow))))
            throw std::exception("QueryService for SID_SShellBrowser, IID_IOleWindow failed in WebBrowser::getCurrentTabHwnd()");
    
        HWND hwndBrowser = NULL;
        if (!SUCCEEDED(pWindow->GetWindow(&hwndBrowser)))
            throw std::exception("GetWindow failed in WebBrowser::getCurrentTabHwnd()");
    
        return hwndBrowser;
    }