欧想在工具条当中添加一个下拉列表筐,该怎么做呢?哪儿有参考代码?

解决方案 »

  1.   

    用ReBar。如果是MFC的程序在APPWIZARD里有选项,大概是在第4步的时候。选了INTERNET EXPLORER REBAR,后面就简单啦。
      

  2.   

    给你一个辅助函数!
    int CMainFrame::CreateMyComboToolBar()
    {
     
    //set up the ComboBox control as a select boxint index = 0;
    CRect rect;
    //ID_MYCOMBO_BOX 是一个标志按钮,用来确定组合框的显示位置
    while(m_wndToolBar.GetItemID(index)!= ID_MYCOMBO_BOX) index++;
    //next convert that button to a 
    //seperator and get its position
    m_wndToolBar.SetButtonInfo(index,
     ID_MYCOMBO_BOX, TBBS_SEPARATOR, COMBO_BOX_WIDTH);
        m_wndToolBar.GetItemRect(index, &rect);
    //expand the rectangle to allow the 
    //combo box room to drop down
        rect.top+=2;
        rect.bottom += 300;    // then .Create the combo box and show it
        if (!m_wndToolBar.m_wndMyComboBox.Create(
            WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL | 
            CBS_DROPDOWNLIST | CBS_HASSTRINGS ,
            rect, &m_wndToolBar, IDC_MYCOMBOX))
        {
            TRACE0("Failed to create combo-box\n");
            return FALSE;
        }
        m_wndToolBar.m_wndMyComboBox.ShowWindow(SW_SHOW);
        //adding string to the combo box
        m_wndToolBar.m_wndMyComboBox.AddString("Fisrt Select");
        m_wndToolBar.m_wndMyComboBox.AddString("Second Select");
        m_wndToolBar.m_wndMyComboBox.AddString("Third Select");
        m_wndToolBar.m_wndMyComboBox.AddString("Fourth Select");
        m_wndToolBar.m_wndMyComboBox.AddString("Fifth Select");
        m_wndToolBar.m_wndMyComboBox.SetCurSel(0);
    return true;
    }