I'm trying to copy the different strings in a listbox into a CString object, and not having much luck.
i'm using the CListBox member function CListBox::GetText, which has the following syntax:
int GetText( int nIndex, LPTSTR lpszBuffer ) const;
But when I use it in a for loop, putting the index of the loop into the <int nIndex> place, i only get the first string. This is my code:
for (i=0; i<count; i++)
int tempLen = m_versionListBox.GetTextLen(i);
char *tempBuf = new char[tempLen];
m_versionListBox.GetText(i, tempBuf); // copy to tempBuf
CString tempString(tempBuf, tempLen);
int debugInt = m_versionListBox.GetCurSel();
i can't figure out what is wrong. (the idea is that I'm trying to copy the values out of the listbox, remove the file extensions from the strings, and copy them back)
The call to GetText(...,...) seems to return the wrong value. Everytime it copies the string from index 0 in the listbox into tempBuf, that seems to be the only problem with the loop.