简体   繁体   中英

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?

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.

“大概是你在OnInitDialog处理程序中执行此操作?如果是这样,您需要将SetFocus设置为列表控件,并从OnInitDialog返回FALSE。”

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM