|
-
November 28th, 2006, 11:50 AM
#1
Owner-draw combo box and compareitem
I was working on creating an owner-draw combo box that would allow me to set the color for each entry. The one catch was that I needed to do this dynamically, so I couldn't turn on the Has Strings flag. I was able to do all of this fairly easily except for one problem.
In my CompareItem() function, the COMPAREITEMSTRUCT never seemed to be right. The second item ID was always -1, and GetLBText didn't work, so I couldn't easily compare the strings. Also, while the first item data pointer seemed to point to my item data, the second points to the string of the item just added.
Is this a known situation and does it work this way for all versions of Win32? That is, can I assume that itemData1 will always contain an actual item data pointer and that itemData2 will always contain the string added by AddString?
I looked around for examples of this, but I couldn't find an example of an owner-draw CComboBox that didn't use "Has Strings" and did use the text. I thought someone had done one for the old MFC mailing list, but I couldn't find it.
-
January 11th, 2007, 07:42 AM
#2
Re: Owner-draw combo box and compareitem
Hi dcell59,
I discovered the same problem (VS 2005, SP1). Worse: In my case the second item in COMPAREITEMSTRUCT delivered to CompareItem() is completely wrong. It always contains senseless data! If this is a bug, we should open a thread in the Bug-Forum.
Regards,
Physicus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|