88712

CListCtrl is not creating groups

Question:

I am trying to make groupings using a CListCtrl trough the following code:

LVGROUP lg = { 0 }; lg.cbSize = sizeof(lg); lg.state = LVGS_NORMAL | LVGS_COLLAPSIBLE; lg.mask = LVGF_GROUPID | LVGF_HEADER | LVGF_STATE | LVGF_ALIGN | LVGF_STATE | LVGF_DESCRIPTIONTOP | LVGF_DESCRIPTIONBOTTOM | LVGF_FOOTER | LVGF_TASK | LVGF_SUBTITLE | LVGF_SUBSET; lg.uAlign = LVGA_HEADER_LEFT | LVGA_FOOTER_RIGHT; LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_GROUPID; item.iSubItem = 0; item.state = 0; item.stateMask = LVIS_SELECTED; CString s; lg.iGroupId = 0; s = L"Office"; lg.pszHeader = s.GetBuffer(); lg.cchHeader = s.GetLength(); pListCtrl->InsertGroup(lg.iGroupId, &lg); item.iGroupId = 0; s = "Pen"; item.pszText = s.GetBuffer(); item.cchTextMax = s.GetLength(); pListCtrl->InsertItem(&item); s = "Pencil"; item.pszText = s.GetBuffer(); item.cchTextMax = s.GetLength(); pListCtrl->InsertItem(&item); lg.iGroupId = 1; s = L"Workshop"; lg.pszHeader = s.GetBuffer(); lg.cchHeader = s.GetLength(); pListCtrl->InsertGroup(lg.iGroupId, &lg); item.iGroupId = 1; s = "Hammer"; item.pszText = s.GetBuffer(); item.cchTextMax = s.GetLength(); pListCtrl->InsertItem(&item); s = "Drill"; item.pszText = s.GetBuffer(); item.cchTextMax = s.GetLength(); pListCtrl->InsertItem(&item); s = "Saw"; item.pszText = s.GetBuffer(); item.cchTextMax = s.GetLength(); pListCtrl->InsertItem(&item);

but everything is shown ungrouped

<a href="https://i.stack.imgur.com/5owsW.png" rel="nofollow"><img alt="ungrouped clistctrl" class="b-lazy" data-src="https://i.stack.imgur.com/5owsW.png" data-original="https://i.stack.imgur.com/5owsW.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

How can I make the groups work as they should?

Answer1:

It turns out there is the need of a manifest, which I added to stdafx.h

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

<a href="https://i.stack.imgur.com/KdbPt.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/KdbPt.png" data-original="https://i.stack.imgur.com/KdbPt.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Recommend

  • ListView_GetItem() macro & LV_GETITEMTEXT returns empty STRING while getting another APP listvie
  • How can I have a multi-line item in a ListControl MFC?
  • use images instead of text in webgrid asp mvc
  • How do I write an item to a DynamoDb with the AWS DynamoDB DocumentClient?
  • Xcode Subversion (SCM) Difference between Refresh and Update
  • jquery draggable stop event
  • What is wrong in my MVC implementation?
  • How to record a JNLP/ Java Web Start application with JMeter
  • Table-per-type inheritance insert problem
  • Selection Sort, For Java
  • Storing a copy of a document embedded in another document in MongoDB via Mongoose
  • Get sibling of Vaadin Tree Item?
  • Telerik Radgrid GridDataItem.DataItem is empty when updating (OnUpdateCommand handler)
  • Nested not working on slide
  • Slowly changing dimension - What is Pure type 6 implementation
  • Loop animation drawable
  • ng-repeat not working with table but works with list
  • Shopify API CARTS - Changing line_item line_price for price Override
  • Simplify where clause with repeated associated type restrictions
  • JQuery Auto-Complete: How do I handle modifications?
  • Removing Duplicate Geometries
  • pandas computation in each group
  • TFS - how do I sum child task hours to parent
  • Dynamically load css stylesheet and wait for it to load
  • Pass array from parent template to child template
  • Wrong row deleted from custom listview with spinner
  • How to load gif image while ajax content is loading and javascript [duplicate]
  • converter json to two dimensional array
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • Simple linked list-C
  • Check all values in string[] for length?
  • How do I alternate colors in Flat List (React Native)
  • Typescript - Unable to get 'import' statement to function
  • How can I send an e-mail from a vbs script
  • Read text file and split every line in MSBuild
  • Align navbar back button on right side
  • Can Jackson SerializationFeature be overridden per field or class?
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How to push additional view controllers onto NavigationController but keep the TabBar?