用ReBar。如果是MFC的程序在APPWIZARD里有选项,大概是在第4步的时候。选了INTERNET EXPLORER REBAR,后面就简单啦。
给你一个辅助函数! 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; }
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;
}