List-View control ignores extended styles

c++, listview, styles, win32gui, winapi

Solution

For list-view controls, extended styles are explicitly set by sending the `LVM_SETEXTENDEDLISTVIEWSTYLE` message to the control window. This is stated in the documentation:

Extended List-View Styles

Use the LVM_SETEXTENDEDLISTVIEWSTYLE message or one of the ListView_SetExtendedListViewStyle or ListView_SetExtendedListViewStyleEx macros to employ these extended list-view control styles.

For example:

SendMessageW(   hWnd,
                LVM_SETEXTENDEDLISTVIEWSTYLE,
                LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES,
                LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

Extended styles apply only after sending this message.

Problem

I create a list-view control with the `CreateWindowEx()` function. The extended styles I specify during the creation do not apply to the list-view control. Here is my code: ``` INITCOMMONCONTROLSEX iccx; iccx.dwSize = sizeof(INITCOMMONCONTROLSEX); iccx.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&iccx); hWnd = CreateWindowExW( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES, // Extended Styles WC_LISTVIEWW, // Class Name L"", // Title LVS_REPORT | WS_VISIBLE | WS_CHILD, // Styles 10, // x 320, // y 480, // w 200, // h hWndParent, NULL, hInstance, NULL); ``` After adding some content to it, the appearance of the list-view is as in the image below. As you see, neither I can select full rows, nor the grid-lines are displayed. What am I missing? How do I make the extended styles show effect?

Original source