Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep row permanently selected in the ListView in Win32

I am using Win32 ListView32.

When row in the ListView is selected it has dark blue color. The row can be selected by either clicking on it or programmatically by calling ListView_SetItemState(hwnd, index, LVIS_SELECTED, LVIS_SELECTED);.

When ListView control focus is lost the selected row becomes gray.

How can I keep selected row with dark blue color irrespective of the focus?

like image 293
LetMe AskYou Avatar asked Feb 03 '12 15:02

LetMe AskYou


3 Answers

Use the LVS_SHOWSELALWAYS window style. I don't think it can stay as dark blue as that's the indicator that that control has focus.

like image 144
Deanna Avatar answered Nov 03 '22 17:11

Deanna


"Presumably you're doing this in a OnInitDialog handler? If so, you need to SetFocus to your list control, and return FALSE from OnInitDialog."

like image 1
Bibin Lukose Avatar answered Nov 03 '22 16:11

Bibin Lukose


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

The definition of the CONTROL in resource file looks like:

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

And The selected item will be highlighted. 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 usr click to other control).

like image 1
Nick Dong Avatar answered Nov 03 '22 16:11

Nick Dong