By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

VC++ CListCtrl question.

P: n/a
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

Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Joseph Smith wrote:
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.
--
Hongzheng Wang

Jul 22 '05 #2

P: n/a
In article <0j******************@news.nnrp.ca>,
Joseph Smith <mo***********@hotmail.com> wrote:

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++.

--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #3

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

"Hongzheng Wang" <wa******@mails.tsinghua.edu.cn> wrote in message
news:bq**********@news.yaako.com...
Joseph Smith wrote:
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.
--
Hongzheng Wang

Jul 22 '05 #4

P: n/a
"Joseph Smith" <mo***********@hotmail.com> wrote in message
news:8f*******************@news.nnrp.ca...
This is the closest group I could find. If you have a better suggestion,
I'm open to it.


Try: microsoft.public.vc.mfc

Also read this: http://www.slack.net/~shiva/welcome.txt

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl


Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.