Listview control - Programmer

This is a discussion on Listview control - Programmer ; Hi, I have developed a dialog-based app using VC++ 6.0 and MFC. I have a CListCtrl on the dialog. This is what I am trying to do: 1) In a for loop, I read information from CSV files line by ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Listview control

  1. Listview control

    Hi,

    I have developed a dialog-based app using VC++ 6.0 and MFC. I have a
    CListCtrl on the dialog. This is what I am trying to do:

    1) In a for loop, I read information from CSV files line by line.
    2) For every line read, it gets tokenized and broken in separate
    values using comma as a delimiter.
    3) I have a class that represents each line read and the class members
    represent token values obtained in step 2. In effect, the class is
    populated with CSV tokens. Lets assume this class to be CLineInfo.

    class CLineInfo
    {
    int Token1
    CString token2;
    double Token3;
    };

    4) So if there are 2000 lines in a file, there will be 2000 instances
    of CFileInfo.

    5) I have to display all this info in a CListCtrl. So I actually pass
    the CFileInfo object's pointer to the LPARAM of LVITEM and specify the
    pszText as TEXT_CALLBACK.

    The code looks like:

    while( fgets(...) != NULL )
    {
    CTokenizer tokenize;
    tokenize.SetLine( Supply line read )

    CStringArray arrTokens;
    tokenize.GetTokens(arrTokens) //Passing the array by reference.

    //Fill CFileInfo with the values.
    CFileInfo *pFileInfo = new CFileInfo(arrTokens);

    //Let say m_lstSpots represents the list control.

    LVITEM lvItem;
    lvItem.pszText = TEXT_CALLBACK;
    lvItem.lParam = (LPARAM) pFileInfo;

    m_lstSpots.InsertItem(lvItem);
    }

    I also implement the OnGetDispInfo for list control.

    However, for 2000 lines, the application speed really decreases. Is
    there any way to increase the speed? I guess this is because there are
    2000 CLineInfo objects in the memory. I even check the application
    space in the task manager, it looks really bloated. Any ideas how this
    can be reduced?

    I would also appreciate if anyone has a better idea to display CSV
    file info in a CListCtrl.

    Thanks in advance.

    Cheers,
    Ups

  2. Re: Listview control

    Use the Virtual mode for CListCtrl - you get each line as it is displayed.
    The advantage is you only retrieve data for the lines actually being
    displayed.

    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "Ups" wrote in message
    news:4b8d27cc.0409012322.61a4a3e3@posting.google.c om...
    > Hi,
    >
    > I have developed a dialog-based app using VC++ 6.0 and MFC. I have a
    > CListCtrl on the dialog. This is what I am trying to do:
    >
    > 1) In a for loop, I read information from CSV files line by line.
    > 2) For every line read, it gets tokenized and broken in separate
    > values using comma as a delimiter.
    > 3) I have a class that represents each line read and the class members
    > represent token values obtained in step 2. In effect, the class is
    > populated with CSV tokens. Lets assume this class to be CLineInfo.
    >
    > class CLineInfo
    > {
    > int Token1
    > CString token2;
    > double Token3;
    > };
    >
    > 4) So if there are 2000 lines in a file, there will be 2000 instances
    > of CFileInfo.
    >
    > 5) I have to display all this info in a CListCtrl. So I actually pass
    > the CFileInfo object's pointer to the LPARAM of LVITEM and specify the
    > pszText as TEXT_CALLBACK.
    >
    > The code looks like:
    >
    > while( fgets(...) != NULL )
    > {
    > CTokenizer tokenize;
    > tokenize.SetLine( Supply line read )
    >
    > CStringArray arrTokens;
    > tokenize.GetTokens(arrTokens) //Passing the array by reference.
    >
    > //Fill CFileInfo with the values.
    > CFileInfo *pFileInfo = new CFileInfo(arrTokens);
    >
    > //Let say m_lstSpots represents the list control.
    >
    > LVITEM lvItem;
    > lvItem.pszText = TEXT_CALLBACK;
    > lvItem.lParam = (LPARAM) pFileInfo;
    >
    > m_lstSpots.InsertItem(lvItem);
    > }
    >
    > I also implement the OnGetDispInfo for list control.
    >
    > However, for 2000 lines, the application speed really decreases. Is
    > there any way to increase the speed? I guess this is because there are
    > 2000 CLineInfo objects in the memory. I even check the application
    > space in the task manager, it looks really bloated. Any ideas how this
    > can be reduced?
    >
    > I would also appreciate if anyone has a better idea to display CSV
    > file info in a CListCtrl.
    >
    > Thanks in advance.
    >
    > Cheers,
    > Ups




  3. Re: Listview control

    Hi,

    Thanks for your help. I will try this out and lets hope it works .
    Cheers.

    upendra.desai@gmail.com (Ups) wrote in message news:<4b8d27cc.0409012322.61a4a3e3@posting.google.com>...
    > Hi,
    >
    > I have developed a dialog-based app using VC++ 6.0 and MFC. I have a
    > CListCtrl on the dialog. This is what I am trying to do:
    >
    > 1) In a for loop, I read information from CSV files line by line.
    > 2) For every line read, it gets tokenized and broken in separate
    > values using comma as a delimiter.
    > 3) I have a class that represents each line read and the class members
    > represent token values obtained in step 2. In effect, the class is
    > populated with CSV tokens. Lets assume this class to be CLineInfo.
    >
    > class CLineInfo
    > {
    > int Token1
    > CString token2;
    > double Token3;
    > };
    >
    > 4) So if there are 2000 lines in a file, there will be 2000 instances
    > of CFileInfo.
    >
    > 5) I have to display all this info in a CListCtrl. So I actually pass
    > the CFileInfo object's pointer to the LPARAM of LVITEM and specify the
    > pszText as TEXT_CALLBACK.
    >
    > The code looks like:
    >
    > while( fgets(...) != NULL )
    > {
    > CTokenizer tokenize;
    > tokenize.SetLine( Supply line read )
    >
    > CStringArray arrTokens;
    > tokenize.GetTokens(arrTokens) //Passing the array by reference.
    >
    > //Fill CFileInfo with the values.
    > CFileInfo *pFileInfo = new CFileInfo(arrTokens);
    >
    > //Let say m_lstSpots represents the list control.
    >
    > LVITEM lvItem;
    > lvItem.pszText = TEXT_CALLBACK;
    > lvItem.lParam = (LPARAM) pFileInfo;
    >
    > m_lstSpots.InsertItem(lvItem);
    > }
    >
    > I also implement the OnGetDispInfo for list control.
    >
    > However, for 2000 lines, the application speed really decreases. Is
    > there any way to increase the speed? I guess this is because there are
    > 2000 CLineInfo objects in the memory. I even check the application
    > space in the task manager, it looks really bloated. Any ideas how this
    > can be reduced?
    >
    > I would also appreciate if anyone has a better idea to display CSV
    > file info in a CListCtrl.
    >
    > Thanks in advance.
    >
    > Cheers,
    > Ups


+ Reply to Thread