我在工具栏里增加了一个COMBO控件,程序编译能够显示,倒COMBO不能下拉,即不能对COMBO进行操作,不知为什么,希望各位大虾帮忙解答
m_wndtoolbar.SetButtonInfo(0,IDC_COMBOBOX,TBBS_SEPARATOR,200);
CRect rect;
m_wndtoolbar.GetItemRect(0,&rect);
rect.bottom = rect.bottom - 1;
rect.top = rect.top + 1;
m_wndComboBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_SORT | CBS_DROPDOWNLIST, rect, this, IDC_COMBOBOX);
m_wndtoolbar.SetButtonInfo(0,IDC_COMBOBOX,TBBS_SEPARATOR,200);
CRect rect;
m_wndtoolbar.GetItemRect(0,&rect);
rect.bottom = rect.bottom - 1;
rect.top = rect.top + 1;
m_wndComboBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_SORT | CBS_DROPDOWNLIST, rect, this, IDC_COMBOBOX);
rect.top = rect.top + 1;
==你设置的控件的高度太小了。搞大一点。这个高度不是你所认为的下拉按钮的高度,而是下拉列表的高度。
rect.bottom = rect.bottom + 100;
rect.bottom = rect.bottom + 600;
bool CLabelChartToolBar::CreateComb()
{
#define COMBO_BOX_WIDTH 120
int index = 0;
CRect rect;
while(GetItemID(index)!= ID_LABEL_LIST)
index++;
SetButtonInfo(index,ID_LABEL_LIST, TBBS_SEPARATOR, COMBO_BOX_WIDTH);
GetItemRect(index, &rect);
rect.top-=1;
rect.bottom += 200;
rect.left+=1;
if (!m_wndLabelChartComb.Create(
WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST | CBS_HASSTRINGS ,
rect, this, IDC_LABELCHART))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndLabelChartComb.ShowWindow(SW_SHOW);
m_wndLabelChartComb.SetCurSel(-1);
return true;
}