怎么我建的CComboBoxEx不能在编辑框中显示所选择的图片而且在下拉列表中被选择的项也不能显示?
代码如下,那里出了错?
class CComboExTestDlg : public CDialog
{public:
CComboBoxEx m_ComboExCtrl;
private:
CImageList m_ImageList;
CBitmap m_pBitmap[4];
HBITMAP m_hPic;
};BOOL CComboExTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
int i;
for(i=0;i<4;i++)
{
m_pBitmap[i].LoadBitmap(IDB_BITMAP1+i);
} m_ImageList.Create(32, 32, ILC_COLOR, 4, 0);
for(i=0;i<4;i++)
{
m_ImageList.Add(&m_pBitmap[i], RGB(0,0,0));
} m_ComboExCtrl.Create(WS_VISIBLE|CBS_DROPDOWNLIST,
CRect(0,0,55,130), this, IDC_COMBOEX);
m_ComboExCtrl.SetImageList(&m_ImageList); COMBOBOXEXITEM comboexitem;
for(i=0;i<4;i++)
{
comboexitem.mask =CBEIF_IMAGE|CBEIF_TEXT;
comboexitem.iItem =i;
comboexitem.pszText ="";
comboexitem.iImage =i;
m_ComboExCtrl.InsertItem(&comboexitem);
} return TRUE;  // return TRUE  unless you set the focus to a control
}

解决方案 »

  1.   

    1. m_ImageList.Create(32, 32, ILC_COLOR|ILC_MASK, 4, 0);
    2. 如果是Icon才需要一个一个Add进ImageList,如果是Bitmap,必须把
    各个图像在同一个Bitmap里并列画好,再一次性Add进ImageList。
    反正问题在于ImageList而不在CComboBoxEx。
    下面是我的测试程序
    http://my.6to23.com/cigarette/dd1.zip
      

  2.   

    bcpl(戒烟直到五颗星) 
    我已经知道了
    是下面的代码
    COMBOBOXEXITEM comboexitem;
    for(i=0;i<4;i++)
    {
    comboexitem.mask =CBEIF_IMAGE|CBEIF_TEXT|CBEIF_SELECTEDIMAGE;
    comboexitem.iItem =i;
    comboexitem.pszText ="faint";
    comboexitem.iSelectedImage =i;
    comboexitem.iImage =i;
    m_ComboExCtrl.InsertItem(&comboexitem);
    }比原来增加了CBEIF_SELECTEDIMAGE选项和comboexitem.iSelectedImage =i;你再试一下