String Selected in ListView List in Win32

I am using Win32 ListView32.

When a row in a ListView is selected, it is blue. You can select a row by clicking on it or programmatically by calling ListView_SetItemState(hwnd, index, LVIS_SELECTED, LVIS_SELECTED); .

When the ListView control focus is lost, the selected row turns gray.

How to save the selected line with blue color regardless of focus?

+7
source share
3 answers

Use the LVS_SHOWSELALWAYS style. I do not think that it can remain dark blue as an indicator that this control has focus.

+2
source

"Presumably, you are doing this in the OnInitDialog handler? If so, you need to SetFocus on your list control and return FALSE from OnInitDialog."

+1
source

If you are using VC6.0. You can set the properties as "Show selection always" in the ListView. And the ListView will be defined by VC6.0 as LVS_SHOWSELALWAYS .

The definition of the CONTROL file in the resource file is as follows:

 CONTROL "List2",IDC_LIST_MEMBER,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,7,64,514,187 

And the selected item is selected. For my program, the default background color is white, the default selected and focused color is blue, and the default selected, but lost focused color is gray (when the user clicks on another control).

+1
source

All Articles