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?
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.
"Presumably you're doing this in a OnInitDialog handler? If so, you need to SetFocus to your list control, and return FALSE from OnInitDialog."
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With