looking for simple example of list-view usage

This is a discussion on looking for simple example of list-view usage within the Windows Programming forums, part of the Platform Specific Boards category; hi, i'm trying to get a list-view control to my app. I wrote related code according to win32api reference, but ...

  1. #1
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71

    Question looking for simple example of list-view usage

    hi,
    i'm trying to get a list-view control to my app. I wrote related code according to win32api reference, but it did not work. I don't know what was wrong, at first i got at least an item inserted, with <null> values (=> my own value inserts failed), later i got various errors and no success at all. I don't want to post any specific code here, think i don't have original version at all, but it still interests me, so i'd like to see simple working list-view. Before i dig myself into net, has anybody seen kind of tutorial on this?
    Thanks

  2. #2
    Registered User Gary's Avatar
    Join Date
    Mar 2002
    Posts
    7
    Check out this site for an excellent example of a ListView:

    http://www.foosyerdoos.fsnet.co.uk/

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    In WIN32 API
    Code:
    HWND            hWnd;//of he listview ctrl
    if(ListView_GetItemCount(hWnd)!=0)
    {
       //CleanUp the old Data
       ListView_DeleteAllItems(hWnd);
       while(ListView_DeleteColumn(hWnd,0)>0);// always delete only the first column over and over
       ListView_SetItemCount(hWnd,0);
    }
    //Find the column width
    GetClientRect(hWnd,&ClientRect);
    iWidth=((ClientRect.right - ClientRect.left)-15)/NUM_COL;//15 for scroll bar
    for(i=0;i<NUM_COL;i++)
    {
        LVColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; 
        LVColumn.fmt = LVCFMT_LEFT;
        LVColumn.cx=iWidth;
        LVColumn.pszText = "Column Title"; 
        LVColumn.cchTextMax = lstrlen("Column Title"); 
        LVColumn.iSubItem = 0; 		
        LVColumn.iImage = 0; 		
        LVColumn.iOrder = 0; 		
        ListView_InsertColumn(hWnd,i,&LVColumn);
    }
    //to insert the items
    LV_ITEM			pItem;
    sprintf(sDescription,"Item text");
    pItem.mask=LVIF_TEXT | LVIF_PARAM;
    pItem.iItem=Row;
    pItem.iSubItem=Column;
    pItem.state=0;
    pItem.stateMask=0;
    pItem.pszText=sDescription;
    pItem.cchTextMax=STRING;//STRING = 64
    pItem.iImage=0;
    pItem.lParam=Row;
    if(Column>=1) //Column is zero based
        ListView_SetItemText(hWnd, Row, Column, sDescription);
    else
       ListView_InsertItem(hWnd, &pItem);
    Last edited by novacain; 04-08-2002 at 09:47 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  2. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  3. List View problem
    By pinkcheese in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2003, 02:09 PM
  4. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 05:20 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21