VC++ CListCtrl question.

J

Joseph Smith

Well I just started playing with VC++ yesterday, so keep it simple if you
can. thx.

Anyway, I'm having problems with a CListCtrl in report view. The first
column seems to display fine, but the other columns don't. Have a look at
my function for adding data:

void CMP3RenamerDlg::populateList(CString str) {

CFileFind finder;

LVITEM lvi;

CString item;

CString strWildcard(str);

strWildcard += _T("\\*.mp3");

BOOL bWorking = finder.FindFile(strWildcard);

int i = 0;

while (bWorking)

{

bWorking = finder.FindNextFile();

if (finder.IsDots())

continue;


// Populate the list with file names.

item = finder.GetFileName();

lvi.mask = LVIF_IMAGE | LVIF_TEXT;

lvi.iItem = i;

lvi.iSubItem = 0;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.InsertItem(&lvi);

lvi.iSubItem = 1;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.SetItem(&lvi);

lvi.iSubItem = 2;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.SetItem(&lvi);

i++;

}

finder.Close();

}



I would think that the code above would put the file name into column 0, 1,
and 2. But it doesn't. Column 0 (the default one) works fine, but on most
of the rows, the other columns aren't populated at all. The couple that do
get populated are populated with the wrong file names. Does anybody have
any idea what it is I'm doing wrong here?



Thanks,

Joseph Smith
 
H

Hongzheng Wang

Joseph said:
Well I just started playing with VC++ yesterday, so keep it simple if you
can. thx.

Anyway, I'm having problems with a CListCtrl in report view. The first
column seems to display fine, but the other columns don't. Have a look at
my function for adding data:

void CMP3RenamerDlg::populateList(CString str) {

CFileFind finder;

LVITEM lvi;

CString item;

CString strWildcard(str);

strWildcard += _T("\\*.mp3");

BOOL bWorking = finder.FindFile(strWildcard);

int i = 0;

while (bWorking)

{

bWorking = finder.FindNextFile();

if (finder.IsDots())

continue;


// Populate the list with file names.

item = finder.GetFileName();

lvi.mask = LVIF_IMAGE | LVIF_TEXT;

lvi.iItem = i;

lvi.iSubItem = 0;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.InsertItem(&lvi);

lvi.iSubItem = 1;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.SetItem(&lvi);

lvi.iSubItem = 2;

lvi.pszText = (LPTSTR)(LPCTSTR)(item);

m_cList.SetItem(&lvi);

i++;

}

finder.Close();

}



I would think that the code above would put the file name into column 0, 1,
and 2. But it doesn't. Column 0 (the default one) works fine, but on most
of the rows, the other columns aren't populated at all. The couple that do
get populated are populated with the wrong file names. Does anybody have
any idea what it is I'm doing wrong here?



Thanks,

Joseph Smith
Here may not be a right place for your question.
 
J

Jon Bell

Anyway, I'm having problems with a CListCtrl in report view.

You had best ask about this in a newsgroup focusing on Windows programming
or on VC++, such as one of the comp.os.ms-windows.programmer.* or
microsoft.public.vc.* groups. Here, people focus on
generic, standard, platform-independent C++.
 
J

Joseph Smith

This is the closest group I could find. If you have a better suggestion,
I'm open to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top