Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Groups in List Controls [modified]

Groups in List Controls [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
databasecareer
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VonHagNDaz
    wrote on last edited by
    #1

    Hey guys, I'm having some problems adding a groups to a list control object. Here is what I'm trying: LVGROUP group; ZeroMemory(&group, sizeof(group)); // Set group group.cbSize = sizeof(group); group.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN; // Convert string value to LPWSTR value for group.pzHeader LPWSTR header = new WCHAR[printableAttributes->name->size() + 1]; MultiByteToWideChar(0, 0, printableAttributes->name->c_str(), -1, header, (int)printableAttributes->name->size() + 1); // Set Group name group.pszHeader = header; group.cchHeader = (int)wcslen(group.pszHeader); group.iGroupId = index; group.uAlign = LVGA_HEADER_CENTER; listControl->InsertGroup(index, &group); // Temporary variables NonCompositeJob* temp; LVITEM item; // Insert items into group for(int i = 0; i < (int)((CompositeJob*)job)->getNoJobs(); i++) { ZeroMemory(&item, sizeof(item)); item.iItem = i; item.mask = LVIF_GROUPID; item.iGroupId = group.iGroupId; item.iSubItem = i + 1; temp = ((CompositeJob*)job)->getJob(i); //Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str()); //Total Copies Printed listControl->SetItemText(i, 1, (LPCTSTR)printableAttributes-> totalNumberOfCopiesPrinted->c_str()); //Job Status listControl->SetItemText(i, 2, (LPCTSTR)printableAttributes-> status->c_str()); //Job Type listControl->SetItemText(i, 3, (LPCTSTR)printableAttributes-> type->c_str()); //File Size listControl->SetItemText(i, 4, (LPCTSTR)printableAttributes-> fileSize->c_str()); //File Location listControl->SetItemText(i, 5, (LPCTSTR)printableAttributes-> fileLocation->c_str()); listControl->SetItemData(i, (DWORD_PTR)temp); listControl->InsertItem(&item); groups is the LSVGROUP object and item is the LVITEM. index is the index of the list control object(listControl). CompositeJob is an object that holds 2+ print jobs. In the loop, I'm trying to add the items one at a time and getNoJobs returns the number of jobs inside of the CompositeJob object. After creating the group, I try to add each item to the group, I set the text of the fields that will be displayed for each of the objects in the group, return to the top of the loop, and continue for each job in the CompositeJob object. -- modified at 10:14 Monday 15th October, 2007 When I add 2 composite j

    N R A 3 Replies Last reply
    0
    • V VonHagNDaz

      Hey guys, I'm having some problems adding a groups to a list control object. Here is what I'm trying: LVGROUP group; ZeroMemory(&group, sizeof(group)); // Set group group.cbSize = sizeof(group); group.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN; // Convert string value to LPWSTR value for group.pzHeader LPWSTR header = new WCHAR[printableAttributes->name->size() + 1]; MultiByteToWideChar(0, 0, printableAttributes->name->c_str(), -1, header, (int)printableAttributes->name->size() + 1); // Set Group name group.pszHeader = header; group.cchHeader = (int)wcslen(group.pszHeader); group.iGroupId = index; group.uAlign = LVGA_HEADER_CENTER; listControl->InsertGroup(index, &group); // Temporary variables NonCompositeJob* temp; LVITEM item; // Insert items into group for(int i = 0; i < (int)((CompositeJob*)job)->getNoJobs(); i++) { ZeroMemory(&item, sizeof(item)); item.iItem = i; item.mask = LVIF_GROUPID; item.iGroupId = group.iGroupId; item.iSubItem = i + 1; temp = ((CompositeJob*)job)->getJob(i); //Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str()); //Total Copies Printed listControl->SetItemText(i, 1, (LPCTSTR)printableAttributes-> totalNumberOfCopiesPrinted->c_str()); //Job Status listControl->SetItemText(i, 2, (LPCTSTR)printableAttributes-> status->c_str()); //Job Type listControl->SetItemText(i, 3, (LPCTSTR)printableAttributes-> type->c_str()); //File Size listControl->SetItemText(i, 4, (LPCTSTR)printableAttributes-> fileSize->c_str()); //File Location listControl->SetItemText(i, 5, (LPCTSTR)printableAttributes-> fileLocation->c_str()); listControl->SetItemData(i, (DWORD_PTR)temp); listControl->InsertItem(&item); groups is the LSVGROUP object and item is the LVITEM. index is the index of the list control object(listControl). CompositeJob is an object that holds 2+ print jobs. In the loop, I'm trying to add the items one at a time and getNoJobs returns the number of jobs inside of the CompositeJob object. After creating the group, I try to add each item to the group, I set the text of the fields that will be displayed for each of the objects in the group, return to the top of the loop, and continue for each job in the CompositeJob object. -- modified at 10:14 Monday 15th October, 2007 When I add 2 composite j

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      And the problem you have are... ?

      Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

      V 1 Reply Last reply
      0
      • N Nelek

        And the problem you have are... ?

        Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

        V Offline
        V Offline
        VonHagNDaz
        wrote on last edited by
        #3

        Sorry, I got lost in the massive message that turned out to be. When I add 2 composite jobs to the list, I end up with 4 entries, two for each one.

        [Insert Witty Sig Here]

        1 Reply Last reply
        0
        • V VonHagNDaz

          Hey guys, I'm having some problems adding a groups to a list control object. Here is what I'm trying: LVGROUP group; ZeroMemory(&group, sizeof(group)); // Set group group.cbSize = sizeof(group); group.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN; // Convert string value to LPWSTR value for group.pzHeader LPWSTR header = new WCHAR[printableAttributes->name->size() + 1]; MultiByteToWideChar(0, 0, printableAttributes->name->c_str(), -1, header, (int)printableAttributes->name->size() + 1); // Set Group name group.pszHeader = header; group.cchHeader = (int)wcslen(group.pszHeader); group.iGroupId = index; group.uAlign = LVGA_HEADER_CENTER; listControl->InsertGroup(index, &group); // Temporary variables NonCompositeJob* temp; LVITEM item; // Insert items into group for(int i = 0; i < (int)((CompositeJob*)job)->getNoJobs(); i++) { ZeroMemory(&item, sizeof(item)); item.iItem = i; item.mask = LVIF_GROUPID; item.iGroupId = group.iGroupId; item.iSubItem = i + 1; temp = ((CompositeJob*)job)->getJob(i); //Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str()); //Total Copies Printed listControl->SetItemText(i, 1, (LPCTSTR)printableAttributes-> totalNumberOfCopiesPrinted->c_str()); //Job Status listControl->SetItemText(i, 2, (LPCTSTR)printableAttributes-> status->c_str()); //Job Type listControl->SetItemText(i, 3, (LPCTSTR)printableAttributes-> type->c_str()); //File Size listControl->SetItemText(i, 4, (LPCTSTR)printableAttributes-> fileSize->c_str()); //File Location listControl->SetItemText(i, 5, (LPCTSTR)printableAttributes-> fileLocation->c_str()); listControl->SetItemData(i, (DWORD_PTR)temp); listControl->InsertItem(&item); groups is the LSVGROUP object and item is the LVITEM. index is the index of the list control object(listControl). CompositeJob is an object that holds 2+ print jobs. In the loop, I'm trying to add the items one at a time and getNoJobs returns the number of jobs inside of the CompositeJob object. After creating the group, I try to add each item to the group, I set the text of the fields that will be displayed for each of the objects in the group, return to the top of the loop, and continue for each job in the CompositeJob object. -- modified at 10:14 Monday 15th October, 2007 When I add 2 composite j

          R Offline
          R Offline
          Roger Broomfield
          wrote on last edited by
          #4

          Have you tried replacing the second InsertItem call with MoveItemToGroup. The result you are seeing is what I would expect with 2 InsertItem calls.

          1 Reply Last reply
          0
          • V VonHagNDaz

            Hey guys, I'm having some problems adding a groups to a list control object. Here is what I'm trying: LVGROUP group; ZeroMemory(&group, sizeof(group)); // Set group group.cbSize = sizeof(group); group.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN; // Convert string value to LPWSTR value for group.pzHeader LPWSTR header = new WCHAR[printableAttributes->name->size() + 1]; MultiByteToWideChar(0, 0, printableAttributes->name->c_str(), -1, header, (int)printableAttributes->name->size() + 1); // Set Group name group.pszHeader = header; group.cchHeader = (int)wcslen(group.pszHeader); group.iGroupId = index; group.uAlign = LVGA_HEADER_CENTER; listControl->InsertGroup(index, &group); // Temporary variables NonCompositeJob* temp; LVITEM item; // Insert items into group for(int i = 0; i < (int)((CompositeJob*)job)->getNoJobs(); i++) { ZeroMemory(&item, sizeof(item)); item.iItem = i; item.mask = LVIF_GROUPID; item.iGroupId = group.iGroupId; item.iSubItem = i + 1; temp = ((CompositeJob*)job)->getJob(i); //Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str()); //Total Copies Printed listControl->SetItemText(i, 1, (LPCTSTR)printableAttributes-> totalNumberOfCopiesPrinted->c_str()); //Job Status listControl->SetItemText(i, 2, (LPCTSTR)printableAttributes-> status->c_str()); //Job Type listControl->SetItemText(i, 3, (LPCTSTR)printableAttributes-> type->c_str()); //File Size listControl->SetItemText(i, 4, (LPCTSTR)printableAttributes-> fileSize->c_str()); //File Location listControl->SetItemText(i, 5, (LPCTSTR)printableAttributes-> fileLocation->c_str()); listControl->SetItemData(i, (DWORD_PTR)temp); listControl->InsertItem(&item); groups is the LSVGROUP object and item is the LVITEM. index is the index of the list control object(listControl). CompositeJob is an object that holds 2+ print jobs. In the loop, I'm trying to add the items one at a time and getNoJobs returns the number of jobs inside of the CompositeJob object. After creating the group, I try to add each item to the group, I set the text of the fields that will be displayed for each of the objects in the group, return to the top of the loop, and continue for each job in the CompositeJob object. -- modified at 10:14 Monday 15th October, 2007 When I add 2 composite j

            A Offline
            A Offline
            Alex Cohn
            wrote on last edited by
            #5

            first, call listControl->InsertItem(&item); Your first call //Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str()); should be converted to listControl->SetItemText(i, 0, (LPCTSTR)printableAttributes-> name->c_str()); BTW, why do you cast to LPCTSTR? If you have your Unicode setting right, it should compile cleanly without the cast; if your Unicode settings are wrong, the cast will not help at runtime. Cheers, Alex

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups