Solved

CComboBoxEx, CImageList, missing images

Posted on 2002-06-19
6
397 Views
Last Modified: 2007-11-27
Hello.

I have CComboBoxEx with images stored in CImageList. In CImageList I have one image for one indicated state of combobox item - each combobox item should have one and only image all the time the comboboxex is displayed.

But when I SW_SHOW this comboboxex (normally it is hidden, I show it just in case it is needed - I empty it, fill with items, show, after selection hide), I see all images OK but the one tied to selected item. Selected item has no image at all - neither in drop down list, nor in edit portion of comboboxex.

Remark: when I tried to add CBEIF_SELECTEDIMAGE and fill in cbi.iSelectedImage member, it had the same behavior.

Thanks - any help would be welcome.

Code for adding items:

     CComboBoxEx*     pCtrl = (CComboBoxEx*)pWnd;
     COMBOBOXEXITEM     cbi;

     pCtrl->ResetContent();
     for (int i = 0; i < arrCislo.GetSize(); i++)
     {
          sItem = arrCislo.GetAt(i).m_sText;

          cbi.mask = CBEIF_IMAGE | CBEIF_TEXT; // CBEIF_SELECTEDIMAGE
          cbi.iItem = i;
          cbi.pszText = (LPTSTR)(LPCTSTR)sItem;
          cbi.cchTextMax = sItem.GetLength();
          cbi.iImage = arrCislo.GetAt(i).m_nTypCD;
          // cbi.iSelectedImage = 1;

          nIndex = pCtrl->InsertItem(&cbi);
          if (nIndex == LB_ERR) break;          

          pMstCislo = new tstMstCislo;
          *pMstCislo = arrCislo.GetAt(i);
          pCtrl->SetItemDataPtr(nIndex, pMstCislo);
     }
     pCtrl->SetImageList(&gb_imgCisDomTyp);
0
Comment
Question by:Martin Bodlák
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7092138
I think gb_imgCisDomTyp have only one image.
The image index starts from 0 (Zero).

Please quote the code, adding images to the list..

Roshmon
0
 

Author Comment

by:Martin Bodlák
ID: 7092160
All those variables are in library together with manipulation functions. I call library function with CComboBoxEx&, which is filled with items and images (see above) and returned.

In ImageList there are three images. In ComboBoxEx, only one image is not shown: the one in selected item. All other images are OK (all kinds of images are seen, if their item is not selected).



static     CBitmap               gb_bmpCisDom_X;          // chybna hodnota
static     CBitmap               gb_bmpCisDom_0;          // neurceno
static     CBitmap               gb_bmpCisDom_P;          // cislo popisne
static     CBitmap               gb_bmpCisDom_E;          // cislo evidencni

static     CImageList          gb_imgCisDomTyp;

     gb_imgCisDomTyp.Create(12, 14, ILC_COLOR, 3, 0);

     gb_bmpCisDom_X.LoadBitmap(IDB_CISDOM_X);
     gb_bmpCisDom_0.LoadBitmap(IDB_CISDOM_0);
     gb_bmpCisDom_P.LoadBitmap(IDB_CISDOM_P);
     gb_bmpCisDom_E.LoadBitmap(IDB_CISDOM_E);

     gb_imgCisDomTyp.Add(&gb_bmpCisDom_0, (CBitmap*) NULL);
     gb_imgCisDomTyp.Add(&gb_bmpCisDom_P, (CBitmap*) NULL);
     gb_imgCisDomTyp.Add(&gb_bmpCisDom_E, (CBitmap*) NULL);
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7092169
check the return value of "Add" function.

Roshmon
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Martin Bodlák
ID: 7092228
You still don't understand me:
All images are loaded into image list, they are OK.
I can see them in ComboBoxEx when I drop down the list.
But as soon as I select any item in list, the list is closed and in edit line of combo there is no image with the selected item.
When I drop down the combo again, all images are OK with exception of the item which is currently selected (= in edit line of combo). This item has no image.
But when I select another item and again drop down the list, the image in the originally selected item is shown, but now the image from currently selected item is not shown.
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 7092251
This is just a guess..

Try to use CBEIF_OVERLAY with selected image and set its index.

Try CBEIF_INDENT  also

GOOD LUCK
0
 

Author Comment

by:Martin Bodlák
ID: 7092286
I worked... Thanks and have a nice day!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question