Solved

CComboBoxEx, CImageList, missing images

Posted on 2002-06-19
6
386 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

861 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

30 Experts available now in Live!

Get 1:1 Help Now