CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 1999
    Posts
    3,585

    CComboBoxEx bitmaps

    I've got some problems with CComboBoxEx...

    1. I've added 4 bitmaps to an image list. The 1st and 3rd represent the unselected state. The 2nd and 4th represent the selected state. The combo has style DROPLIST. When I mouse over each item, the previous state of an item is not changing. For example, mouse over item one and its state bitmap changes. Now, mouse over item two and its state image changes, but, item one's image remains as it was.

    2. Is there any way to remove text from the display? Can I display only a bitmap, or, am I locked into a bitmap and text?

    Any help is greatly appreciated.
    Gort...Klaatu, Barada Nikto!

  2. #2
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: CComboBoxEx bitmaps

    Can you show some code how you are chainging the item state? And when?
    2. Is there any way to remove text from the display? Can I display only a bitmap, or, am I locked into a bitmap and text?
    I don't understand it. Can you give an example or to explain it.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  3. #3
    Join Date
    Apr 1999
    Posts
    3,585

    Re: CComboBoxEx bitmaps

    CComboBoxEx uses the COMBOBOXEXITEM structure to insert items. If you do not specify a value for pszText, you end up with something like "|" displayed where the text would normally display. For #2, I'd like to display the bitmap but not the text.
    Gort...Klaatu, Barada Nikto!

  4. #4
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: CComboBoxEx bitmaps

    if you do specify the like this pszText="";?

  5. #5
    Join Date
    Apr 1999
    Posts
    3,585

    Re: CComboBoxEx bitmaps

    I tried that. It also displays "|".
    Gort...Klaatu, Barada Nikto!

  6. #6
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: CComboBoxEx bitmaps

    Quote Originally Posted by Mike Harnad
    I tried that. It also displays "|".
    Yes that is true. My suggestion is that to try with DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) to draw the icons. I know that is not the best way but if you want that not display the text I think this is the only solution.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  7. #7
    Join Date
    Apr 1999
    Posts
    3,585

    Re: CComboBoxEx bitmaps

    Yes, I already have such an implentation. I was hoping to replace it with some of the features of CComboBoxEx. But, it appears that it's too buggy right now to be useful.

    Thanks for your input.
    Gort...Klaatu, Barada Nikto!

  8. #8
    Join Date
    Jul 2003
    Posts
    147

    Re: CComboBoxEx bitmaps

    I am doing something similar with the CComboBoxEx. I am not doing multiple states, but am using icons with no text ....

    Code:
       CImageList image_list;
       image_list.Create(150,16,ILC_COLOR4,7,1);
       image_list.Add(theApp.LoadIcon(LINE_SOLID));
       image_list.Add(theApp.LoadIcon(LINE_DASH));
       image_list.Add(theApp.LoadIcon(LINE_DOT));
       image_list.Add(theApp.LoadIcon(LINE_DASH_DOT));
       image_list.Add(theApp.LoadIcon(LINE_DASH_DOT_DOT));
       image_list.Add(theApp.LoadIcon(LINE_CLEAR));
       image_list.Add(theApp.LoadIcon(LINE_SMALL_DOTS));
    
       CComboBoxEx combo;
       combo.SetImageList(&image_list);
    
       COMBOBOXEXITEM item;
       ::ZeroMemory(&item,sizeof(item));
       item.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE;
       item.iItem = TChart::psSolid;
       item.iImage = TChart::psSolid;
       item.iSelectedImage = TChart::psSolid;
       item.pszText = "";
       combo.InsertItem(&item);
    
       item.iItem = TChart::psDash;
       item.iImage = TChart::psDash;
       item.iSelectedImage = TChart::psDash;
       item.pszText = "";
       combo.InsertItem(&item);
    
       .... init all the items ....
    Good Luck!
    "Live only for tomorrow, and you will have a lot of empty yesterdays today."

  9. #9
    Join Date
    Apr 1999
    Posts
    3,585

    Re: CComboBoxEx bitmaps

    tmecham: thanks for taking a look at this. I changed the code to use the same bitmap for the selected and unselected image. I can live wth that. However, I can't seem to get rid of the vertical bar when I don't specify text for each item. Take look at the attached bitmap.
    Attached Images Attached Images  
    Gort...Klaatu, Barada Nikto!

  10. #10
    Join Date
    Jul 2003
    Posts
    147

    Re: CComboBoxEx bitmaps

    When I change the size of my combo box, I guess I am seeing the same thing. It's just that my bitmaps are a little wider than my combo box, so I don't see the empty string being highlighted. So I guess one way to get around it would be to do what I did, and make your bitmaps wider using whitespace. Kind of stupid to have to do that, but I can confirm that it works ...
    "Live only for tomorrow, and you will have a lot of empty yesterdays today."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured