Extended ComboBox添加图标
关键点
实现过程
// MFC02Dlg.h : header file CImageList m_imageList; // MFC02Dlg.cpp : implementation file BOOL CMFC02Dlg::OnInitDialog() // TODO: Add extra initialization here m_imageList.Create(16, 16, ILC_COLOR|ILC_MASK, 4, 4); m_imageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON1))); m_imageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON2))); m_imageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON3))); ((CComboBoxEx*)GetDlgItem(IDC_COMBOBOXEX1))->SetImageList(&m_imageList); for(int i=0; i<m_imageList.GetImageCount(); i++) { COMBOBOXEXITEM cbi ={0}; int nItem; cbi.mask = CBEIF_IMAGE | CBEIF_INDENT | CBEIF_OVERLAY |CBEIF_SELECTEDIMAGE | CBEIF_TEXT; cbi.iItem = i; CString str; str.Format(_T("Numb %2d"), i); cbi.pszText = (LPTSTR)(LPCTSTR)str; cbi.cchTextMax = str.GetLength(); cbi.iImage = i; cbi.iSelectedImage = i; cbi.iOverlay = 2; cbi.iIndent = 0;//(i & 0x03); //Set indentation according //to item position nItem =((CComboBoxEx*)GetDlgItem(IDC_COMBOBOXEX1))->InsertItem(&cbi); ASSERT(nItem == i); } ((CComboBoxEx*)GetDlgItem(IDC_COMBOBOXEX1))->SetCurSel(0); |
图
备注
来至win-rar
如何添加ComboboxEx的文本内容 使用AddString 出错
相关链接