CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006

    Question Adding Dialog box to KBBar sample toolbar


    I have downloaded the famous KBBar Microsoft sample to create a custom tool bar.

    I want to make the first button as the login button and pop up a dialog box when the user clicks it.

    I created the Dialog class but can't seem to call the DoModal() method. It doesn't work through the command() method. If I put the call in create(), to test, it does pop up so I know that there isn't any problem with my class creation.

    Can someone help me to understand how to do this. I am new to C++ so any detailed help will be appreciated.

    Thank you,

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Lahore, Pakistan

    Re: Adding Dialog box to KBBar sample toolbar

    Welcome aboard.

    Well, when asking for some specific problem, plz provide as much details as you can. Like which Microsoft sample we are talking about here? How you have implemented it, what errors do you get. Most likely, others senior members will be able to dig out the problem for you, if needed, they'll ask you to provide the complete code. But with vague information, its not possible to provide some concrete solution. I hope you understand what I mean

  3. #3
    Join Date
    Jun 2006

    Question Re: Adding Dialog box to KBBar sample toolbar

    Thanks for taking a look.

    Let me explain it further;

    The KBBar is the sample to create IE Toolbar. Here is the link to download the code;


    Download and unzip the file to get the source code / files.

    KBToolbarCtrl.cpp is the file used to control the actions from the toolbar buttons.
    I have added a Dialog class (base class is CDialog) to the project.

    I can successfully invoke the dialog when I put the dlg.DoModal(); statement in
    bool CKBToolBarCtrl::Create(CRect rcClientParent, CWnd* pWndParent, CKBBarBand* pBand) method but this is not what I need.

    I want to invoke my dialog when I click on the first button of the toolbar.
    Here is the onCommand function of the cpp file

    void CKBToolBarCtrl::OnCommand()

    const MSG* pMsg = GetCurrentMessage();

    int nID = LOWORD(pMsg->wParam);
    _variant_t varEmpty;
    _variant_t varURL;

    switch (nID)
    case ID_BUTTON1:
    // varURL = _bstr_t(g_MSDNURL);
    // m_pBand->m_pIE->Navigate2(&varURL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);

    myint = dlg.DoModal();

    case ID_BUTTON2:
    varURL = _bstr_t(g_WWURL);
    m_pBand->m_pIE->Navigate2(&varURL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);

    Case ID_BUTTON1 works fine if I uncomment this code to go to a url but if I put this myint = dlg.DoModal(); there, it doesn't pop the dialog on click.

    Hope I was clear;

    Thanks for the help,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.