Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:09+00:00 2026-05-24T18:42:09+00:00

A browser helper object I’m writing at the moment needs to alert the user

  • 0

A browser helper object I’m writing at the moment needs to alert the user of certain situations.
I don’t want to use the WinAPI function MessageBox, because it forces the user to click it away.
Is there a possibillity to ask the user a question without blocking his workflow? He should be able to just ignore the question, if he isn’t interested in it at the moment.
Something like gBrowser.getNotificationBox() for firefox extensions would be ideal (example image appended). Firefox gBrowser.getNotificationBox()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:42:10+00:00Added an answer on May 24, 2026 at 6:42 pm

    I finally could solve it. The answer below and the answers in this question did help me. There you can also find some more information about this problem.
    If someone has the same problem, here is my code. I don’t think it will compile without the rest of my projects code, but it should give an idea, how to implement such a dialog box in a browser helper object:

    Header:

    #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;
    };
    

    Source:

    #include "NotificationBar.hpp"
    
    NotificationBar::NotificationBar()
        :isShown(false)
    {
    }
    
    void NotificationBar::show(const std::string &message)
    {
        show();
        setText(message);
    }
    
    void NotificationBar::show()
    {
        if(isShown)
        {
            fitSize();
            return;
        }
        isShown=true;
    
        WebBrowser webbrowser(BrowserHelperObject::getInstance().getBrowser());
        //Create dialog
        Create(webbrowser.getCurrentTabHwnd());
        //Set dialog size
        fitSize();
        ShowWindow(SW_SHOWNORMAL);
    }
    
    void NotificationBar::hide()
    {
        if(!isShown) return;
        ShowWindow(SW_HIDE);
        DestroyWindow();
        isShown=false;
        fitSize();
    }
    
    void NotificationBar::fitSize()
    {
        //This method is highly non portable. I is possible that it will not work in future versions of
        //Internet explorer. It is dependend on the layout of the IE window and on the class names
        //of its child windows (status bar, document view, ...).
        //If the plugin gets some strange layout on future versions of IE or doesn't show a message at all,
        //check and change this function.
    
        WebBrowser webbrowser(BrowserHelperObject::getInstance().getBrowser());
        CWindow tab(webbrowser.getCurrentTabHwnd());
        CWindow child(FindWindowEx(tab,NULL,_T("Shell DocObject View"),_T("")));
        CWindow statusbar(FindWindowEx(tab,NULL,_T("msctls_statusbar32"),_T("")));
    
        RECT statusbarrect;
        statusbar.GetWindowRect(&statusbarrect);
        RECT documentrect;
        tab.GetClientRect(&documentrect);
        documentrect.bottom-=(statusbarrect.bottom-statusbarrect.top);
    
        if(isShown)
        {
            //Request document window rect
            static const unsigned int DLGHEIGHT=50;
            RECT dialogrect=documentrect;
            documentrect.top+=DLGHEIGHT;
            dialogrect.bottom=dialogrect.top+DLGHEIGHT;
            //Shrink document window
            MoveWindow(&dialogrect);
        }
    
        child.MoveWindow(&documentrect);
    }
    
    LRESULT NotificationBar::OnBnClickedCancel(WORD, WORD, HWND , BOOL&)
    {
        hide();
        return 0;
    }
    
    void NotificationBar::setText(const std::string &text)
    {
        if(0==SetDlgItemText(IDC_TEXT, CA2W(text.c_str())))
            ieaddon::util::bho::BrowserHelperObject::getInstance().ErrorMessageBox("Error",ieaddon::util::cast::IntToStr(GetLastError()));
    }
    

    The function webbrowser.getCurrentTabHwnd() returns the current tab window:

    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;
    }
    

    You also have to call NotificationBar::fitSize() on each resize of the browser window. For this you can use IHTMLWindow3::attachEvent(_T(“onresize”),…) in the DocumentComplete event of IE.

    Here the way to get an instance of IHTMLWindow3 in the DocumentComplete handler:

    1. IWebBrowser2::getDocument() returns IHTMLDocument2
    2. IHTMLDocument2::get_parentWindow() returns IHTMLWindow2
    3. IHTMLWindow2::QueryInterface(IID_IHTMLWindow3,…) is successful
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Browser Helper Object (BHO) for Internet Explorer in C#! I want
I’m writing a BHO (Browser Helper Object) that catches the address the user enters
I am writing a Browser Helper Object for ie7, and I need to detect
My bho (Browser Helper Object) is a sidebar (right-sided iframe) that needs to be
I'm busy writing a BHO(Browser Helper Object) in C# and I need to attach
I am developing a Browser Helper Object running inside Internet Explorer. I am writing
I have a Browser Helper Object project in c# that (obviously) references shdocvw.dll. I
For a university project I programmed a Internet Explorer Browser Helper Object to process
I have written a browser helper object to get the text between the tags
I am trying to write a Browser Helper Object (BHO) in C# that manipulates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.