Groups in List Controls [modified]
-
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 -
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 jAnd 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 ;)
-
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 ;)
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]
-
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 jHave you tried replacing the second InsertItem call with MoveItemToGroup. The result you are seeing is what I would expect with 2 InsertItem calls.
-
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 jfirst, call
listControl->InsertItem(&item);
Your first call//Name listControl->InsertItem(i, (LPCTSTR)printableAttributes-> name->c_str());
should be converted tolistControl->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