Solved

Please help me asap! Combo Box + List Control Error

Posted on 2003-10-30
1
179 Views
Last Modified: 2013-11-20
Program Layout:

Cedit = m_strFile   // Prints the path of the file which contains the album (mp3's)
ComboBox = m_ComboBands // A list of bands
List Control = m_MyAlbums // the name of the bands albums
Button1 = Browse
Button2 = Rename
Button3 = Stop

What this program does is... once a file is selected. You then select which band it is on the comb box and then the list control shows the current bands album names, after selecting one you press rename and it renames the mp3's in the selected file.

Since you have an idea of my program. I have been having problems with getting the selection of the combo box to the list control. After compileing my code, i select a 311 and it displays both 311 and Adema. Please help me!

Heres my code.....

void CMp3RenamerDlg::OnSelchangeCombo1()
{
     char nSelection = m_ComboBands.GetCurSel();

     if( nSelection != LB_ERR )
     {
          if( nSelection, "311" )
          {
                                            m_MyAlbums.DeleteAllItems();
                m_MyAlbums.InsertItem(0, _T( "Music" ));
                m_MyAlbums.SetItemText(0,1, "1993");
               m_MyAlbums.InsertItem(0, _T("Self Titled"));
               m_MyAlbums.SetItemText(0,1, _T("1996"));
                 m_MyAlbums.InsertItem(0, _T("Transistor"));
                m_MyAlbums.SetItemText(0,1, _T("1997"));
               m_MyAlbums.InsertItem(0, _T("Live"));
               m_MyAlbums.SetItemText(0,1, _T("1998"));
                m_MyAlbums.InsertItem(0, _T("Soundsystem"));
                m_MyAlbums.SetItemText(0,1, _T("1999"));
               m_MyAlbums.InsertItem(0, _T("Grassroots"));
               m_MyAlbums.SetItemText(0,1, _T("2000"));
                m_MyAlbums.InsertItem(0, _T("From Chaos"));
                m_MyAlbums.SetItemText(0,1, _T("2001"));
               m_MyAlbums.InsertItem(0, _T("Evolver"));
               m_MyAlbums.SetItemText(0,1, _T("2003"));
          }
          if( nSelection, "Adema" )
          {
                                              m_MyAlbums.DeleteAllItems();
               m_MyAlbums.InsertItem(0, _T("Self Titled"));
               m_MyAlbums.SetItemText(0,1, _T("2001"));    
          }
     }
}
0
Comment
Question by:khaotiksociety
1 Comment
 
LVL 8

Accepted Solution

by:
martynjpearson earned 50 total points
Comment Utility
Your syntax is wrong in the two if statements where you check for "311" and "Adema"

What you need to do is get the text from the combo box for the selected item, and then compare that with the text strings, thus :

if (nSelection != CB_ERR) // Not LB_ERR, although the two are the same thing!
{
   CString strText;
   m_ComboBands.GetLBText(nSelection, strText);

   if (strText == "311")
   {
      // ...
   }
   else if (strText == "Adema")
   {
      // ...
   }
}

Hope this helps
Martyn
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now