List view without images...

This is a discussion on List view without images... within the Windows Programming forums, part of the Platform Specific Boards category; Can it be done? After several days of messing around with this control, and not finding any online examples that ...

  1. #1
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256

    List view without images...

    Can it be done? After several days of messing around with this control, and not finding any online examples that don't use an image list, I'm wondering if the fact that I'm not supplying one is causing the control to fail and display none of the items I add to it, even though LVM_INSERTITEM returns successfully every time.

    Is an image list required for the control, or am I just missing something else? Is there another control that might work better that I don't know about? I'd use a ListBox if it could handle subitems.
    Code:
    void function(void)
     {
      function();
     }

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    I think an image list would be required, unless the ListView is in details mode (which acts quite like a listbox, except with subitems). Is details mode what you want, and did you set the style appropriately? If so, did you add the columns? (Items will not show until you add columns.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Details/Report view is what I am going for. When I first started working on it, within my actual project, I added two columns, yes. When nothing came up, I figured I was doing it wrong, so I opened a test project to experiment with the control a bit, and since I decided to start with just a single column in the test, I did not add any columns. Are column inserts required when only a single column is being used?

    Here's the more important bits of code from the test project...

    Code:
      HWND hList = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, WC_LISTVIEW, NULL,
                                  WS_CHILD | WS_VISIBLE | LVS_REPORT,
                                  0, 0, 300, 300,
                                  hwnd, 0, hInstance, NULL);
      if(hList == NULL)
       {
        printf("CreateWindowEx() Failure\n");
        return 0;
       }
    
      LVITEM ItemInfo;
      ZeroMemory(&ItemInfo, sizeof(ItemInfo));
      ItemInfo.mask = LVIF_TEXT;
      ItemInfo.iSubItem   = 0;
    
      ItemInfo.iItem      = 0;
      ItemInfo.pszText    = "Test Account #1";
      ItemInfo.cchTextMax = 20;
      uint result = SendMessage(hList, LVM_INSERTITEM, 0, (LPARAM)&ItemInfo);
      if(result == -1)
        printf("LVM_INSERTITEM Failure\n");
      else
        printf("LVM_INSERTITEM Success: %i\n", result);
      SendMessage(hList, LVM_SETITEMTEXT, 0, (LPARAM)&ItemInfo);
    
      ItemInfo.iItem      = 1;
      ItemInfo.pszText    = "Test Account #2";
      ItemInfo.cchTextMax = 20;
      result = SendMessage(hList, LVM_INSERTITEM, 0, (LPARAM)&ItemInfo);
      if(result == -1)
        printf("LVM_INSERTITEM Failure\n");
      else
        printf("LVM_INSERTITEM Success: %i\n", result);
      SendMessage(hList, LVM_SETITEMTEXT, 1, (LPARAM)&ItemInfo);
    
      ItemInfo.iItem      = 2;
      ItemInfo.pszText    = "Test Account #3";
      ItemInfo.cchTextMax = 20;
      result = SendMessage(hList, LVM_INSERTITEM, 0, (LPARAM)&ItemInfo);
      if(result == -1)
        printf("LVM_INSERTITEM Failure\n");
      else
        printf("LVM_INSERTITEM Success: %i\n", result);
      SendMessage(hList, LVM_SETITEMTEXT, 1, (LPARAM)&ItemInfo);
    Note that I have called InitCommonControlsEx().
    Code:
    void function(void)
     {
      function();
     }

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Yes -- even for single column listviews, you need to add that column.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Subitem 0 or 1 for a single column?
    Code:
    void function(void)
     {
      function();
     }

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by Jaken Veina View Post
    Subitem 0 or 1 for a single column?
    zero

    I find the Listview_XX macros helpful (ie Listview_InsertItem())

    item is row,
    subitem is column.
    both are zero based.
    If you delete rows (items) the remaining rows are re-numbered.

    Set the listview to REPORT style
    Add the columns
    Listview_InsertItem only for a new item (create a new row with this entry in the first col)
    ListView_SetItemText() for each other col [subitem] in the row (apart from the first col).
    "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

  7. #7
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Excellent! All is well. Thanks a bunch.
    Code:
    void function(void)
     {
      function();
     }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circularly linked list
    By BlackOps in forum C Programming
    Replies: 0
    Last Post: 07-18-2009, 08:12 AM
  2. Anyone good with linked list.....I am not....
    By chadsxe in forum C++ Programming
    Replies: 11
    Last Post: 11-10-2005, 01:48 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. List View problem
    By pinkcheese in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2003, 01:09 PM
  5. link list
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 12-13-2001, 04:41 AM

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