Listview的API全集(2)--------www.mvps.org

thorkhan 2002-04-11 10:32:50

Public Function ListView_CreateDragImage(hWnd As Long, i As Long, lpptUpLeft As POINTAPI) As Long
ListView_CreateDragImage = SendMessage(hWnd, LVM_CREATEDRAGIMAGE, ByVal i, lpptUpLeft)
End Function

Public Function ListView_GetViewRect(hWnd As Long, prc As RECT) As Boolean
ListView_GetViewRect = SendMessage(hWnd, LVM_GETVIEWRECT, 0, prc)
End Function

Public Function ListView_GetTextColor(hWnd As Long) As Long
ListView_GetTextColor = SendMessage(hWnd, LVM_GETTEXTCOLOR, 0, 0)
End Function

Public Function ListView_SetTextColor(hWnd As Long, clrText As Long) As Boolean
ListView_SetTextColor = SendMessage(hWnd, LVM_SETTEXTCOLOR, 0, ByVal clrText)
End Function

Public Function ListView_GetTextBkColor(hWnd As Long) As Long
ListView_GetTextBkColor = SendMessage(hWnd, LVM_GETTEXTBKCOLOR, 0, 0)
End Function

Public Function ListView_SetTextBkColor(hWnd As Long, clrTextBk As Long) As Boolean
ListView_SetTextBkColor = SendMessage(hWnd, LVM_SETTEXTBKCOLOR, 0, ByVal clrTextBk)
End Function

Public Function ListView_GetTopIndex(hwndLV As Long) As Long
ListView_GetTopIndex = SendMessage(hwndLV, LVM_GETTOPINDEX, 0, 0)
End Function

Public Function ListView_GetCountPerPage(hwndLV As Long) As Long
ListView_GetCountPerPage = SendMessage(hwndLV, LVM_GETCOUNTPERPAGE, 0, 0)
End Function

Public Function ListView_GetOrigin(hwndLV As Long, ppt As POINTAPI) As Boolean
ListView_GetOrigin = SendMessage(hwndLV, LVM_GETORIGIN, 0, ppt)
End Function

Public Function ListView_Update(hwndLV As Long, i As Long) As Boolean
ListView_Update = SendMessage(hwndLV, LVM_UPDATE, ByVal i, 0)
End Function

Public Function ListView_SetItemState(hwndLV As Long, i As Long, state As LVITEM_state, mask As LVITEM_state) As Boolean
Dim lvi As LVITEM
lvi.state = state
lvi.stateMask = mask
ListView_SetItemState = SendMessage(hwndLV, LVM_SETITEMSTATE, ByVal i, lvi)
End Function

Public Function ListView_GetItemState(hwndLV As Long, i As Long, mask As LVITEM_state) As Long ' LVITEM_state
ListView_GetItemState = SendMessage(hwndLV, LVM_GETITEMSTATE, ByVal i, ByVal mask)
End Function

#If (WIN32_IE >= &H300) Then

Public Function ListView_GetCheckState(hwndLV As Long, iIndex As Long) As Long ' updated
Dim dwState As Long
dwState = SendMessage(hwndLV, LVM_GETITEMSTATE, ByVal iIndex, ByVal LVIS_STATEIMAGEMASK)
ListView_GetCheckState = (dwState \ 2 ^ 12) - 1
'((((UINT)(SendMessage(hwndLV, LVM_GETITEMSTATE, ByVal i, LVIS_STATEIMAGEMASK))) >> 12) -1)
End Function
'
#End If

Public Sub ListView_GetItemText(hwndLV As Long, i As Long, iSubItem As Long, _
pszText As Long, cchTextMax As Long)
Dim lvi As LVITEM
lvi.iSubItem = iSubItem
lvi.cchTextMax = cchTextMax
lvi.pszText = pszText
SendMessage hwndLV, LVM_GETITEMTEXT, ByVal i, lvi
pszText = lvi.pszText ' fills pszText w/ pointer
End Sub

Public Sub ListView_SetItemText(hwndLV As Long, i As Long, iSubItem As Long, pszText As Long)
Dim lvi As LVITEM
lvi.iSubItem = iSubItem
lvi.pszText = pszText
SendMessage hwndLV, LVM_SETITEMTEXT, ByVal i, lvi
End Sub

Public Sub ListView_SetItemCount(hwndLV As Long, cItems As Long)
SendMessage hwndLV, LVM_SETITEMCOUNT, ByVal cItems, 0
End Sub

#If (WIN32_IE >= &H300) Then

Public Sub ListView_SetItemCountEx(hwndLV As Long, cItems As Long, dwFlags As Long)
SendMessage hwndLV, LVM_SETITEMCOUNT, ByVal cItems, ByVal dwFlags
End Sub
'
#End If

Public Function ListView_SortItems(hwndLV As Long, pfnCompare As Long, lParamSort As Long) As Boolean
ListView_SortItems = SendMessage(hwndLV, LVM_SORTITEMS, ByVal lParamSort, ByVal pfnCompare)
End Function

Public Sub ListView_SetItemPosition32(hwndLV As Long, i As Long, x As Long, y As Long)
Dim ptNewPos As POINTAPI
ptNewPos.x = x
ptNewPos.y = y
SendMessage hwndLV, LVM_SETITEMPOSITION32, ByVal i, ptNewPos
End Sub

Public Function ListView_GetSelectedCount(hwndLV As Long) As Long
ListView_GetSelectedCount = SendMessage(hwndLV, LVM_GETSELECTEDCOUNT, 0, 0)
End Function

Public Function ListView_GetItemSpacing(hwndLV As Long, fSmall As Boolean) As Long
ListView_GetItemSpacing = SendMessage(hwndLV, LVM_GETITEMSPACING, ByVal fSmall, 0)
End Function

Public Function ListView_GetISearchString(hwndLV As Long, lpsz As String) As Boolean
ListView_GetISearchString = SendMessage(hwndLV, LVM_GETISEARCHSTRING, 0, ByVal lpsz)
End Function

' =============================================================
' the next three macros are user-defined

' Returns the index of the item that is selected and has the focus rectangle

Public Function ListView_GetSelectedItem(hwndLV As Long) As Long
ListView_GetSelectedItem = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED Or LVNI_SELECTED)
End Function

' Selects the specified item and gives it the focus rectangle.
' does not de-select any currently selected items

Public Function ListView_SetSelectedItem(hwndLV As Long, i As Long) As Boolean
ListView_SetSelectedItem = ListView_SetItemState(hwndLV, i, LVIS_FOCUSED Or LVIS_SELECTED, _
LVIS_FOCUSED Or LVIS_SELECTED)
End Function

' Selects all listview items. The item with the focus rectangle maintains it.

Public Function ListView_SelectAll(hwndLV As Long) As Boolean
ListView_SelectAll = ListView_SetItemState(hwndLV, -1, LVIS_SELECTED, LVIS_SELECTED)
End Function
...全文
443 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Brunhild 2002-04-12
  • 打赏
  • 举报
回复
mark
wgku 2002-04-11
  • 打赏
  • 举报
回复
UP
thorkhan 2002-04-11
  • 打赏
  • 举报
回复
終于貼完了﹐這是我以前在www.mvps.org找到的﹕
Listview的API全集(1)-----http://www.csdn.net/expert/topic/640/640091.xml?temp=.8425867
Listview的API全集(2)-----http://www.csdn.net/expert/topic/640/640101.xml?temp=.6100885
Treeview的API全集(1)-----http://www.csdn.net/expert/topic/640/640108.xml?temp=.347912
Treeview的API全集(2)-----http://www.csdn.net/expert/topic/640/640109.xml?temp=.3793146
Mike_sun 2002-04-11
  • 打赏
  • 举报
回复
hehe
thorkhan 2002-04-11
  • 打赏
  • 举报
回复
' ==============================================================
#If (WIN32_IE >= &H300) Then
'
' // -1 for cx and cy means we'll use the default (system settings)
' // 0 for cx or cy means use the current setting (allows you to change just one param)
Public Function ListView_SetIconSpacing(hwndLV As Long, cx As Long, cy As Long) As Long
ListView_SetIconSpacing = SendMessage(hwndLV, LVM_SETICONSPACING, 0, ByVal MAKELONG(cx, cy))
End Function

Public Function ListView_SetExtendedListViewStyle(hwndLV As Long, dw As Long) As Long
ListView_SetExtendedListViewStyle = SendMessage(hwndLV, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal dw)
End Function

Public Function ListView_GetExtendedListViewStyle(hwndLV As Long) As Long
ListView_GetExtendedListViewStyle = SendMessage(hwndLV, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
End Function

Public Function ListView_GetSubItemRect(hWnd As Long, iItem As Long, iSubItem As Long, _
code As Long, prc As RECT) As Boolean
prc.Top = iSubItem
prc.Left = code
ListView_GetSubItemRect = SendMessage(hWnd, LVM_GETSUBITEMRECT, ByVal iItem, prc)
End Function

Public Function ListView_SubItemHitTest(hWnd As Long, plvhti As LVHITTESTINFO) As Long
ListView_SubItemHitTest = SendMessage(hWnd, LVM_SUBITEMHITTEST, 0, plvhti)
End Function

Public Function ListView_SetColumnOrderArray(hWnd As Long, iCount As Long, lpiArray As Long) As Boolean
ListView_SetColumnOrderArray = SendMessage(hWnd, LVM_SETCOLUMNORDERARRAY, ByVal iCount, lpiArray)
End Function

Public Function ListView_GetColumnOrderArray(hWnd As Long, iCount As Long, lpiArray As Long) As Boolean
ListView_GetColumnOrderArray = SendMessage(hWnd, LVM_GETCOLUMNORDERARRAY, ByVal iCount, lpiArray)
End Function

Public Function ListView_SetHotItem(hWnd As Long, i As Long) As Long
ListView_SetHotItem = SendMessage(hWnd, LVM_SETHOTITEM, ByVal i, 0)
End Function

Public Function ListView_GetHotItem(hWnd As Long) As Long
ListView_GetHotItem = SendMessage(hWnd, LVM_GETHOTITEM, 0, 0)
End Function

Public Function ListView_SetHotCursor(hWnd As Long, hcur As Long) As Long
ListView_SetHotCursor = SendMessage(hWnd, LVM_SETHOTCURSOR, 0, ByVal hcur)
End Function

Public Function ListView_GetHotCursor(hWnd As Long) As Long
ListView_GetHotCursor = SendMessage(hWnd, LVM_GETHOTCURSOR, 0, 0)
End Function

Public Function ListView_ApproximateViewRect(hWnd As Long, iWidth As Long, _
iHeight As Long, iCount As Long) As Long
ListView_ApproximateViewRect = SendMessage(hWnd, _
LVM_APPROXIMATEVIEWRECT, _
ByVal iCount, _
ByVal MAKELPARAM(iWidth, iHeight))
End Function
'
#End If ' ' WIN32_IE >= &H300
'

' ==============================================================
#If (WIN32_IE >= &H400) Then

Public Function ListView_SetUnicodeFormat(hWnd As Long, fUnicode As Boolean) As Boolean
ListView_SetUnicodeFormat = SendMessage(hWnd, LVM_SETUNICODEFORMAT, ByVal fUnicode, 0)
End Function

Public Function ListView_GetUnicodeFormat(hWnd As Long) As Boolean
ListView_GetUnicodeFormat = SendMessage(hWnd, LVM_GETUNICODEFORMAT, 0, 0)
End Function

Public Function ListView_SetExtendedListViewStyleEx(hwndLV As Long, dwMask As Long, dw As Long) As Long
ListView_SetExtendedListViewStyleEx = SendMessage(hwndLV, LVM_SETEXTENDEDLISTVIEWSTYLE, _
ByVal dwMask, ByVal dw)
End Function

Public Function ListView_SetWorkAreas(hWnd As Long, nWorkAreas As Long, prc() As RECT) As Boolean
ListView_SetWorkAreas = SendMessage(hWnd, LVM_SETWORKAREAS, ByVal nWorkAreas, prc(0))
End Function

Public Function ListView_GetWorkAreas(hWnd As Long, nWorkAreas, prc() As RECT) As Boolean
ListView_GetWorkAreas = SendMessage(hWnd, LVM_GETWORKAREAS, ByVal nWorkAreas, prc(0))
End Function

Public Function ListView_GetNumberOfWorkAreas(hWnd As Long, pnWorkAreas As Long) As Boolean
ListView_GetNumberOfWorkAreas = SendMessage(hWnd, LVM_GETNUMBEROFWORKAREAS, 0, pnWorkAreas)
End Function

Public Function ListView_GetSelectionMark(hWnd As Long) As Long
ListView_GetSelectionMark = SendMessage(hWnd, LVM_GETSELECTIONMARK, 0, 0)
End Function

Public Function ListView_SetSelectionMark(hWnd As Long, i As Long) As Long
ListView_SetSelectionMark = SendMessage(hWnd, LVM_SETSELECTIONMARK, 0, ByVal i)
End Function

Public Function ListView_SetHoverTime(hwndLV As Long, dwHoverTimeMs As Long) As Long
ListView_SetHoverTime = SendMessage(hwndLV, LVM_SETHOVERTIME, 0, ByVal dwHoverTimeMs)
End Function

Public Function ListView_GetHoverTime(hwndLV As Long) As Long
ListView_GetHoverTime = SendMessage(hwndLV, LVM_GETHOVERTIME, 0, 0)
End Function

Public Function ListView_SetToolTips(hwndLV As Long, hwndNewHwnd As Long) As Long
ListView_SetToolTips = SendMessage(hwndLV, LVM_SETTOOLTIPS, ByVal hwndNewHwnd, 0)
End Function

Public Function ListView_GetToolTips(hwndLV As Long) As Long
ListView_GetToolTips = SendMessage(hwndLV, LVM_GETTOOLTIPS, 0, 0)
End Function

Public Function ListView_SetBkImage(hWnd As Long, plvbki As LVBKIMAGE) As Boolean
ListView_SetBkImage = SendMessage(hWnd, LVM_SETBKIMAGE, 0, plvbki)
End Function

Public Function ListView_GetBkImage(hWnd As Long, plvbki As LVBKIMAGE) As Boolean
ListView_GetBkImage = SendMessage(hWnd, LVM_GETBKIMAGE, 0, plvbki)
End Function

#End If ' WIN32_IE >= &H400

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧