请选择 进入手机版 | 继续访问电脑版

玩酷之家

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 573|回复: 0

当ListView失去焦点时选中内容背景为灰色

[复制链接]

92

主题

97

帖子

361

积分

中级会员

Rank: 3Rank: 3

积分
361
发表于 2018-4-28 11:15:17 | 显示全部楼层 |阅读模式
当ListView失去焦点时选中内容背景为灰色

  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  2. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  3. Private Const GWL_STYLE As Long = (-16)
  4. Private Const LVS_SHOWSELALWAYS As Long = &H8&



  5. Private Sub Form_Load()
  6.    
  7.    
  8.    
  9.     Dim lStyles As Long
  10.    
  11.     'Get current styles
  12.     lStyles = GetWindowLong(ListView1.hwnd, GWL_STYLE)
  13.    
  14.     If (lStyles And LVS_SHOWSELALWAYS) = LVS_SHOWSELALWAYS Then
  15.         'Remove the LVS_SHOWSELALWAYS style
  16.         lStyles = lStyles And Not LVS_SHOWSELALWAYS
  17.     Else
  18.         'Add the LVS_SHOWSELALWAYS style
  19.         lStyles = lStyles Or LVS_SHOWSELALWAYS
  20.     End If
  21.    
  22.     Call SetWindowLong(ListView1.hwnd, GWL_STYLE, lStyles)
  23.     ListView1.Refresh
  24.    
  25.    
  26.    
  27.     With ListView1
  28.         .ListItems.Add , , "Item 1"
  29.         .ListItems.Add , , "Item 2"
  30.         .ListItems.Add , , "Item 3"
  31.         .ListItems.Add , , "Item 4"
  32.         .ListItems.Add , , "Item 5"
  33.     End With
  34.    
  35. End Sub
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|玩酷之家 ( 鄂ICP备14012049号-1 )

GMT+8, 2018-12-12 15:32 , Processed in 0.155371 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表