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
Solved

CComboBoxEx, CImageList, missing images

Posted on 2002-06-19
6
394 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 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