Solved

CComboBoxEx, CImageList, missing images

Posted on 2002-06-19
6
380 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
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
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
Comment Utility
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
Comment Utility
check the return value of "Add" function.

Roshmon
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Martin Bodlák
Comment Utility
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
Comment Utility
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
Comment Utility
I worked... Thanks and have a nice day!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now