-
August 14th, 2011, 09:45 PM
#1
listbox selection
HI. new to the board and ive gotten stuck on a listbox problem. making a simple media player and i have a button, that when a listbox file in the listbox is selected, it will play.
.....(simple explanation) it is my play button. .............select mp3 in listbox and hit play
I know I have to use getcursel ...tried but no luck
i have no problem playing the sound file with mci commands. i just wanted to master the listbox
-
August 16th, 2011, 03:16 PM
#2
Re: listbox selection
I assume the text on the list items is the filename for the file you want to play?
Keep in mind that LB_GETCURSEL only returns the numeric index of the selected item. You'll need to use LB_GETTEXT with that index to get the actual text of the list item.
You may want something like this:
Code:
TCHAR szFilename[MAX_PATH];
int iCurSel = SendMessage(hWndList, LB_GETCURSEL, 0, 0);
SendMessage(hWndList, LB_GETTEXT, iCurSel, (LPARAM)szFilename);
//Use MCI functions to play szFilename here.
-
August 16th, 2011, 03:38 PM
#3
Re: listbox selection
May I ask why do you have to suffer using what might be so much error-prone ?
I use only MFC, I know it might be a little overweighted a framework to load into the executable. But it is helpful.
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
|