VC++ CListCtrl question.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joseph Smith

    VC++ CListCtrl question.

    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(C String 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.FindNext File();

    if (finder.IsDots( ))

    continue;


    // Populate the list with file names.

    item = finder.GetFileN ame();

    lvi.mask = LVIF_IMAGE | LVIF_TEXT;

    lvi.iItem = i;

    lvi.iSubItem = 0;

    lvi.pszText = (LPTSTR)(LPCTST R)(item);

    m_cList.InsertI tem(&lvi);

    lvi.iSubItem = 1;

    lvi.pszText = (LPTSTR)(LPCTST R)(item);

    m_cList.SetItem (&lvi);

    lvi.iSubItem = 2;

    lvi.pszText = (LPTSTR)(LPCTST R)(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



  • Hongzheng Wang

    #2
    Re: VC++ CListCtrl question.

    Joseph Smith wrote:[color=blue]
    > 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(C String 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.FindNext File();
    >
    > if (finder.IsDots( ))
    >
    > continue;
    >
    >
    > // Populate the list with file names.
    >
    > item = finder.GetFileN ame();
    >
    > lvi.mask = LVIF_IMAGE | LVIF_TEXT;
    >
    > lvi.iItem = i;
    >
    > lvi.iSubItem = 0;
    >
    > lvi.pszText = (LPTSTR)(LPCTST R)(item);
    >
    > m_cList.InsertI tem(&lvi);
    >
    > lvi.iSubItem = 1;
    >
    > lvi.pszText = (LPTSTR)(LPCTST R)(item);
    >
    > m_cList.SetItem (&lvi);
    >
    > lvi.iSubItem = 2;
    >
    > lvi.pszText = (LPTSTR)(LPCTST R)(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
    >
    >
    >[/color]
    Here may not be a right place for your question.


    --
    Hongzheng Wang

    Comment

    • Jon Bell

      #3
      Re: VC++ CListCtrl question.

      In article <0jXzb.44$UM.15 000698@news.nnr p.ca>,
      Joseph Smith <monkeythumper@ hotmail.com> wrote:[color=blue]
      >
      >Anyway, I'm having problems with a CListCtrl in report view.[/color]

      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.program mer.* or
      microsoft.publi c.vc.* groups. Here, people focus on
      generic, standard, platform-independent C++.

      --
      Jon Bell <jtbellap8@pres by.edu> Presbyterian College
      Dept. of Physics and Computer Science Clinton, South Carolina USA

      Comment

      • Joseph Smith

        #4
        Re: VC++ CListCtrl question.

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

        "Hongzheng Wang" <wanghz02@mails .tsinghua.edu.c n> wrote in message
        news:bqpg9t$1sh $1@news.yaako.c om...[color=blue]
        > Joseph Smith wrote:[color=green]
        > > Well I just started playing with VC++ yesterday, so keep it simple if[/color][/color]
        you[color=blue][color=green]
        > > 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[/color][/color]
        at[color=blue][color=green]
        > > my function for adding data:
        > >
        > > void CMP3RenamerDlg: :PopulateList(C String 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.FindNext File();
        > >
        > > if (finder.IsDots( ))
        > >
        > > continue;
        > >
        > >
        > > // Populate the list with file names.
        > >
        > > item = finder.GetFileN ame();
        > >
        > > lvi.mask = LVIF_IMAGE | LVIF_TEXT;
        > >
        > > lvi.iItem = i;
        > >
        > > lvi.iSubItem = 0;
        > >
        > > lvi.pszText = (LPTSTR)(LPCTST R)(item);
        > >
        > > m_cList.InsertI tem(&lvi);
        > >
        > > lvi.iSubItem = 1;
        > >
        > > lvi.pszText = (LPTSTR)(LPCTST R)(item);
        > >
        > > m_cList.SetItem (&lvi);
        > >
        > > lvi.iSubItem = 2;
        > >
        > > lvi.pszText = (LPTSTR)(LPCTST R)(item);
        > >
        > > m_cList.SetItem (&lvi);
        > >
        > > i++;
        > >
        > > }
        > >
        > > finder.Close();
        > >
        > > }
        > >
        > >
        > >
        > > I would think that the code above would put the file name into column 0,[/color][/color]
        1,[color=blue][color=green]
        > > and 2. But it doesn't. Column 0 (the default one) works fine, but on[/color][/color]
        most[color=blue][color=green]
        > > of the rows, the other columns aren't populated at all. The couple that[/color][/color]
        do[color=blue][color=green]
        > > get populated are populated with the wrong file names. Does anybody[/color][/color]
        have[color=blue][color=green]
        > > any idea what it is I'm doing wrong here?
        > >
        > >
        > >
        > > Thanks,
        > >
        > > Joseph Smith
        > >
        > >
        > >[/color]
        > Here may not be a right place for your question.
        >
        >
        > --
        > Hongzheng Wang
        >[/color]


        Comment

        • Peter van Merkerk

          #5
          Re: VC++ CListCtrl question.

          "Joseph Smith" <monkeythumper@ hotmail.com> wrote in message
          news:8f8Ab.56$z W3.27997309@new s.nnrp.ca...[color=blue]
          > This is the closest group I could find. If you have a better suggestion,
          > I'm open to it.[/color]

          Try: microsoft.publi c.vc.mfc

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

          --
          Peter van Merkerk
          peter.van.merke rk(at)dse.nl




          Comment

          Working...