Jump to content
  • Advertisement
Sign in to follow this  
GetWindowRect

Listbox design question.

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a wrapper class for a listbox. In the listbox I want each item to have a 2 text values. I want to have 1 of the text values to go into the listbox as normal, but I want to be able to select out a different value than what is displayed. For example. I am playing around with c++ trying to make an MP3 player. As of now, I have the filename in a listbox and you can select an item and play it. However it is the whole file location. I would like to somehow just display the song, yet have it hold the file location in a hidden array/vector so I could select it out for the selected item. The question is, what would be the best way of going about this. I have rarely used vectors, but I could make a vector of char* or strings, and each time an item is added into the listbox, put the value to be selected in the vector, the problems with this method are: 1) If the listbox is sorted how could I "sort" the items in the vector according to the listbox, rather than by the items in the vector. 2) How would I be able to tell which item in the vector to remove when an item in the listbox is deleted. I am sure I could think of more problems but those are just examples. Is there an easier method to go about doing this, or any ideas? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
duh... give it up. nothing's simpler than subclassing an mfc class

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
DUH handle all the standard messages to be handled in the base class

Share this post


Link to post
Share on other sites
Quote:
duh... give it up. nothing's simpler than subclassing an mfc class

I don't want to use the MFC or subclass any of its classes.

Quote:
Original post by Anonymous Poster
DUH handle all the standard messages to be handled in the base class

handle the messages to do what? I still need to store the value somewhere, or am I missing what you mean? If you insist on saying "DUH", try to make a post that makes a little more sense, I already handle all the adding through my class, my question is how would I store the second text value in order to be retrieved again.

Thanks anyway.

Share this post


Link to post
Share on other sites
You can use the item data of every item to store a value or a pointer to a struct. More specifically, look into the functions SetItemData and GetItemData.

Use that item data to find the pairs of display text and actual item value.

Share this post


Link to post
Share on other sites
Thank you Endurion for the reply, although the only SetItemData/GetItemData functions I can find are for the MFC which I am not using, I am using Win32 API to learn how things work. If I am incorrect please let me know, otherwise I will keep looking for a solution.

Share this post


Link to post
Share on other sites
Nevermind my last post, I found LB_SETITEMDATA and LB_GETITEMDATA messages that I can use with SendMessage, I will look into how to use them correctly, thank you again Endurion. Much appreciated.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!