Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have made a ListCtrl with a type of as follows:


item1100.mask = LVIF_TEXT;
item1100.pszText = _T("");
item1100.iItem = i;
item1100.iImage = 0;
item1100.state = 0;

DWORD dwEXStyle = m_List_1100.GetExtendedStyle();
m_List_1100.SetExtendedStyle(dwEXStyle | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT );


When I click one row, the color of the selected row is strong blue, but if I click another items within same UI, the color of original row change from strong blue to gray.

In this case, how do I keep the original color of selected row of ListCtrl?

Thank you in advance.

What I have tried:

2 more days wasted for this problem.
Posted
Updated 1-Dec-16 21:44pm

1 solution

This is the default UI behaviour of Windows. If a list control does not has the focus, selected items are shown with a grey background.

The only solution to use a different colour in this case would be using a custom drawn list handling the NM_CUSTOMDRAW (list view) notification code (Windows)[^]. But then you must set the colours for all possible states inside that handler and skip the default drawing because selected and hot items are drawn by the system at last.

But I would not do so. It would break the standard UI behaviour and you would have to get the colours actually used by the system for selected items (the user may have selected a different theme where the selection background colour is not blue).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900