ListYS.bas
资源名称:qq.rar [点击查看]
上传用户:luoweizhao
上传日期:2022-08-01
资源大小:1290k
文件大小:5k
源码类别:
外挂编程
开发平台:
Visual Basic
- Attribute VB_Name = "ListYS"
- '
- '----------------------By 陈锐------------------------------
- '如果你要在Internet或BBS上转贴文章,请通知我知道
- 'Email: blackcat@nease.net develope@163.net
- '请参观我的站点 http://www.nease.net/~blackcat
- Option Explicit
- Private Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Private Type DRAWITEMSTRUCT
- CtlType As Long '控件类型
- CtlID As Long '控件ID
- itemID As Long '菜单项、列表框或组合框中某一项的索引值
- itemAction As Long '控件行为
- itemState As Long '控件状态
- hwndItem As Long '父窗口句柄或菜单句柄
- hdc As Long '控件对应的绘图设备句柄
- rcItem As RECT '控件所占据的矩形区域
- itemData As Long '列表框或组合框中某一项的值
- End Type
- Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
- Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
- Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
- Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
- Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
- Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
- Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
- Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
- Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
- Private Const COLOR_HIGHLIGHT = 13
- Private Const COLOR_HIGHLIGHTTEXT = 14
- Private Const COLOR_WINDOW = 5
- Private Const COLOR_WINDOWTEXT = 8
- Private Const LB_GETTEXT = &H189
- Private Const WM_DRAWITEM = &H2B
- Private Const GWL_WNDPROC = (-4)
- Private Const ODS_FOCUS = &H10
- Private Const ODT_LISTBOX = 2
- Private lPrevWndProc As Long
- Private Function SubClassedList(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- On Error Resume Next
- Dim tItem As DRAWITEMSTRUCT
- Dim sBuff As String * 255
- Dim sItem As String
- Dim tem As String
- Dim lBack As Long
- If Msg = WM_DRAWITEM Then '绘制菜单消息
- Call CopyMemory(tItem, ByVal lParam, Len(tItem))
- If tItem.CtlType = ODT_LISTBOX Then '只处理控件类型为listbox的控件
- Call SendMessage(tItem.hwndItem, LB_GETTEXT, tItem.itemID, ByVal sBuff) '获得具体值
- sItem = Replace(sBuff, Chr(0), "")
- If (tItem.itemState And ODS_FOCUS) Then '判断某项是否具有焦点
- lBack = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT))
- Call FillRect(tItem.hdc, tItem.rcItem, lBack)
- Call SetBkColor(tItem.hdc, GetSysColor(COLOR_HIGHLIGHT))
- Call SetTextColor(tItem.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT))
- TextOut tItem.hdc, tItem.rcItem.Left, tItem.rcItem.Top, ByVal sItem, Len(sItem)
- DrawFocusRect tItem.hdc, tItem.rcItem
- Else '如果没有焦点,则
- lBack = CreateSolidBrush(GetSysColor(COLOR_WINDOW))
- Call FillRect(tItem.hdc, tItem.rcItem, lBack)
- Call SetBkColor(tItem.hdc, GetSysColor(COLOR_WINDOW))
- Call SetTextColor(tItem.hdc, tItem.itemData)
- TextOut tItem.hdc, tItem.rcItem.Left, tItem.rcItem.Top, ByVal sItem, Len(sItem)
- End If
- Call DeleteObject(lBack)
- SubClassedList = 0
- Exit Function
- End If
- End If
- SubClassedList = CallWindowProc(lPrevWndProc, hWnd, Msg, wParam, lParam)
- End Function
- Public Sub SubLists(ByVal hWnd As Long)
- lPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf SubClassedList)
- End Sub
- Public Sub RemoveSubLists(ByVal hWnd As Long)
- Call SetWindowLong(hWnd, GWL_WNDPROC, lPrevWndProc)
- End Sub