Listview

Signaler
Messages postés
84
Date d'inscription
jeudi 24 janvier 2002
Statut
Membre
Dernière intervention
4 avril 2006
-
Messages postés
550
Date d'inscription
jeudi 12 octobre 2006
Statut
Membre
Dernière intervention
6 juin 2015
-
j'aimerai savoir s'il existe un tutorial sur les listviews. C'est surtout par rapport à la gestion des icones que j'aimerai savoir comment ça se passe.

1 réponse

Messages postés
550
Date d'inscription
jeudi 12 octobre 2006
Statut
Membre
Dernière intervention
6 juin 2015
4
Tiens cadeaux:Option ExplicitDefLng A-Z#Const WIN32_IE = &H400'-------------------------------------------' Klaus H. Probst [kprobst@xxxxxxxxx]' http://www.vbbox.com/'-------------------------------------------'// Thanks to Brad Martinez (http://www.mvps.org/ccrp/), from whose EnumDeskVB2 sample'// I pulled this in a hurry to avoid translating the CommCtrl.H SDK file and put'// this sample together.'// From the EnumDeskVB2 project, this is a combination of the LVDefs_471.bas and'// LVMacros_471.bas modules, pulled together for simplicity.'//'// The only modification is the removal of the _UNICODEFORMAT messages and the'// typing of the lpszText members of some structures and macros from Long to'// String to facilitate manipulation from VB. But if something here doesn't'// work, contact *me*, not him, OK?Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)Public Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypePublic Type Point 'APIX As SingleY As SingleEnd TypePrivate Type POINTAPIX As LongY As LongEnd TypePrivate Type NMHDRhwndFrom As LongidFrom As Longcode As LongEnd TypePrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPublic Const WC_LISTVIEW = "SysListView32"Public Enum LVStylesLVS_ICON = &H0LVS_REPORT = &H1LVS_SMALLICON = &H2LVS_LIST = &H3LVS_TYPEMASK = &H3LVS_SINGLESEL = &H4LVS_SHOWSELALWAYS = &H8LVS_SORTASCENDING = &H10LVS_SORTDESCENDING = &H20LVS_SHAREIMAGELISTS = &H40LVS_NOLABELWRAP = &H80LVS_AUTOARRANGE = &H100LVS_EDITLABELS = &H200#If (WIN32_IE >= &H300) ThenLVS_OWNERDATA = &H1000#End IfLVS_NOSCROLL = &H2000LVS_TYPESTYLEMASK = &HFC00LVS_ALIGNTOP = &H0LVS_ALIGNLEFT = &H800LVS_ALIGNMASK = &HC00LVS_OWNERDRAWFIXED = &H400LVS_NOCOLUMNHEADER = &H4000LVS_NOSORTHEADER = &H8000&End Enum ' LVStylesPublic Const WS_VSCROLL As Long = &H200000Public Const WS_HSCROLL As Long = &H100000' ============================================' MessagesPublic Enum LVMessagesLVM_FIRST = &H1000LVM_GETBKCOLOR = (LVM_FIRST + 0)LVM_SETBKCOLOR = (LVM_FIRST + 1)LVM_GETIMAGELIST = (LVM_FIRST + 2)LVM_SETIMAGELIST = (LVM_FIRST + 3)LVM_GETITEMCOUNT = (LVM_FIRST + 4)#If UNICODE ThenLVM_GETITEM = (LVM_FIRST + 75)LVM_SETITEM = (LVM_FIRST + 76)LVM_INSERTITEM = (LVM_FIRST + 77)#ElseLVM_GETITEM = (LVM_FIRST + 5)LVM_SETITEM = (&H1000 + 6)LVM_INSERTITEM = (LVM_FIRST + 7)#End IfLVM_DELETEITEM = (LVM_FIRST + 8)LVM_DELETEALLITEMS = (LVM_FIRST + 9)LVM_GETCALLBACKMASK = (LVM_FIRST + 10)LVM_SETCALLBACKMASK = (LVM_FIRST + 11)LVM_GETNEXTITEM = (LVM_FIRST + 12)#If UNICODE ThenLVM_FINDITEM = (LVM_FIRST + 83)#ElseLVM_FINDITEM = (LVM_FIRST + 13)#End IfLVM_GETITEMRECT = (LVM_FIRST + 14)LVM_SETITEMPOSITION = (LVM_FIRST + 15)LVM_GETITEMPOSITION = (LVM_FIRST + 16)#If UNICODE ThenLVM_GETSTRINGWIDTH = (LVM_FIRST + 87)#ElseLVM_GETSTRINGWIDTH = (LVM_FIRST + 17)#End IfLVM_HITTEST = (LVM_FIRST + 18)LVM_ENSUREVISIBLE = (LVM_FIRST + 19)LVM_SCROLL = (LVM_FIRST + 20)LVM_REDRAWITEMS = (LVM_FIRST + 21)LVM_ARRANGE = (LVM_FIRST + 22)#If UNICODE ThenLVM_EDITLABEL = (LVM_FIRST + 118)#ElseLVM_EDITLABEL = (LVM_FIRST + 23)#End IfLVM_GETEDITCONTROL = (LVM_FIRST + 24)#If UNICODE ThenLVM_GETCOLUMN = (LVM_FIRST + 95)LVM_SETCOLUMN = (LVM_FIRST + 96)LVM_INSERTCOLUMN = (LVM_FIRST + 97)#ElseLVM_GETCOLUMN = (LVM_FIRST + 25)LVM_SETCOLUMN = (LVM_FIRST + 26)LVM_INSERTCOLUMN = (LVM_FIRST + 27)#End IfLVM_DELETECOLUMN = (LVM_FIRST + 28)LVM_GETCOLUMNWIDTH = (LVM_FIRST + 29)LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30)#If (WIN32_IE >= &H300) ThenLVM_GETHEADER = (LVM_FIRST + 31)#End IfLVM_CREATEDRAGIMAGE = (LVM_FIRST + 33)LVM_GETVIEWRECT = (LVM_FIRST + 34)LVM_GETTEXTCOLOR = (LVM_FIRST + 35)LVM_SETTEXTCOLOR = (LVM_FIRST + 36)LVM_GETTEXTBKCOLOR = (LVM_FIRST + 37)LVM_SETTEXTBKCOLOR = (LVM_FIRST + 38)LVM_GETTOPINDEX = (LVM_FIRST + 39)LVM_GETCOUNTPERPAGE = (LVM_FIRST + 40)LVM_GETORIGIN = (LVM_FIRST + 41)LVM_UPDATE = (LVM_FIRST + 42)LVM_SETITEMSTATE = (LVM_FIRST + 43)LVM_GETITEMSTATE = (LVM_FIRST + 44)#If UNICODE ThenLVM_GETITEMTEXT = (LVM_FIRST + 115)LVM_SETITEMTEXT = (LVM_FIRST + 116)#ElseLVM_GETITEMTEXT = (LVM_FIRST + 45)LVM_SETITEMTEXT = (LVM_FIRST + 46)#End IfLVM_SETITEMCOUNT = (LVM_FIRST + 47)LVM_SORTITEMS = (LVM_FIRST + 48)LVM_SETITEMPOSITION32 = (LVM_FIRST + 49)LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50)LVM_GETITEMSPACING = (LVM_FIRST + 51)#If UNICODE ThenLVM_GETISEARCHSTRING = (LVM_FIRST + 117)#ElseLVM_GETISEARCHSTRING = (LVM_FIRST + 52)#End If#If (WIN32_IE >= &H300) ThenLVM_SETICONSPACING = (LVM_FIRST + 53)LVM_SETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 54)LVM_GETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 55)LVM_GETSUBITEMRECT = (LVM_FIRST + 56)LVM_SUBITEMHITTEST = (LVM_FIRST + 57)LVM_SETCOLUMNORDERARRAY = (LVM_FIRST + 58)LVM_GETCOLUMNORDERARRAY = (LVM_FIRST + 59)LVM_SETHOTITEM = (LVM_FIRST + 60)LVM_GETHOTITEM = (LVM_FIRST + 61)LVM_SETHOTCURSOR = (LVM_FIRST + 62)LVM_GETHOTCURSOR = (LVM_FIRST + 63)LVM_APPROXIMATEVIEWRECT = (LVM_FIRST + 64)#End If ' // WIN32_IE >= &H300#If (WIN32_IE >= &H400) ThenLVM_SETWORKAREAS = (LVM_FIRST + 65)LVM_GETWORKAREAS = (LVM_FIRST + 70)LVM_GETNUMBEROFWORKAREAS = (LVM_FIRST + 73)LVM_GETSELECTIONMARK = (LVM_FIRST + 66)LVM_SETSELECTIONMARK = (LVM_FIRST + 67)LVM_SETHOVERTIME = (LVM_FIRST + 71)LVM_GETHOVERTIME = (LVM_FIRST + 72)LVM_SETTOOLTIPS = (LVM_FIRST + 74)LVM_GETTOOLTIPS = (LVM_FIRST + 78)#If UNICODE ThenLVM_SETBKIMAGE = (LVM_FIRST + 138)LVM_GETBKIMAGE = (LVM_FIRST + 139)#ElseLVM_SETBKIMAGE = (LVM_FIRST + 68)LVM_GETBKIMAGE = (LVM_FIRST + 69)#End If#End If ' // WIN32_IE >= &H400'#If (WIN32_IE >= &H400) Then' LVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT' LVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT'#End IfEnd Enum ' LVMessagesPublic Const LV_MAX_WORKAREAS = 16' LVM_GETIMAGELIST wParamPublic Enum LVSIL_FlagsLVSIL_NORMAL = 0LVSIL_SMALL = 1LVSIL_STATE = 2End Enum' LVM_GETNEXTITEM flagsPublic Enum LVNI_FlagsLVNI_ALL = &H0LVNI_FOCUSED = &H1LVNI_SELECTED = &H2LVNI_CUT = &H4LVNI_DROPHILITED = &H8LVNI_ABOVE = &H100LVNI_BELOW = &H200LVNI_TOLEFT = &H400LVNI_TORIGHT = &H800End Enum' LVM_GETITEMRECT rct.LeftPublic Enum LVIR_FlagsLVIR_BOUNDS = 0LVIR_ICON = 1LVIR_LABEL = 2LVIR_SELECTBOUNDS = 3End Enum' LVM_ARRANGE wParamPublic Enum LVA_FlagsLVA_DEFAULT = &H0LVA_ALIGNLEFT = &H1LVA_ALIGNTOP = &H2LVA_SNAPTOGRID = &H5End Enum' ============================================' StructuresPublic Type LVITEM ' was LV_ITEMmask As LVITEM_maskiItem As LongiSubItem As Longstate As LVITEM_statestateMask As Long'pszText As Long ' if String, must be pre-allocatedpszText As String ' if String, must be pre-allocatedcchTextMax As LongiImage As LonglParam As Long#If (WIN32_IE >= &H300) TheniIndent As Long#End IfEnd Type#If (WIN32_IE >= &H300) ThenPublic Const I_INDENTCALLBACK = (-1) ' iIndent, 4.70#End IfPublic Enum LVITEM_maskLVIF_TEXT = &H1LVIF_IMAGE = &H2LVIF_PARAM = &H4LVIF_STATE = &H8#If (WIN32_IE >= &H300) ThenLVIF_INDENT = &H10LVIF_NORECOMPUTE = &H800#End IfLVIF_DI_SETITEM = &H1000 ' NMLVDISPINFO notificationEnd EnumPublic Enum LVITEM_stateLVIS_FOCUSED = &H1LVIS_SELECTED = &H2LVIS_CUT = &H4LVIS_DROPHILITED = &H8LVIS_ACTIVATING = &H20LVIS_OVERLAYMASK = &HF00LVIS_STATEIMAGEMASK = &HF000End EnumPublic Type LVFINDINFO ' was LV_FINDINFOflags As LVFINDINFO_flagspsz As Long ' if String, must be pre-allocatedlParam As Longpt As POINTAPIvkDirection As LongEnd TypePublic Enum LVFINDINFO_flagsLVFI_PARAM = &H1LVFI_STRING = &H2LVFI_PARTIAL = &H8LVFI_WRAP = &H20LVFI_NEARESTXY = &H40End EnumPublic Type LVHITTESTINFO ' was LV_HITTESTINFOpt As POINTAPIflags As LVHITTESTINFO_flagsiItem As Long#If (WIN32_IE >= &H300) TheniSubItem As Long ' this is was NOT in win95. valid only for LVM_SUBITEMHITTEST#End IfEnd TypePublic Enum LVHITTESTINFO_flagsLVHT_NOWHERE = &H1 ' in LV client area, but not over itemLVHT_ONITEMICON = &H2LVHT_ONITEMLABEL = &H4LVHT_ONITEMSTATEICON = &H8LVHT_ONITEM = (LVHT_ONITEMICON Or LVHT_ONITEMLABEL Or LVHT_ONITEMSTATEICON)' outside the LV's client areaLVHT_ABOVE = &H8LVHT_BELOW = &H10LVHT_TORIGHT = &H20LVHT_TOLEFT = &H40End EnumPublic Type LVCOLUMN ' was LV_COLUMNmask As LVCOLUMN_maskfmt As LVCOLUMN_fmtcx As Long'pszText As Long ' if String, must be pre-allocatedpszText As String ' if String, must be pre-allocatedcchTextMax As LongiSubItem As Long#If (WIN32_IE >= &H300) TheniImage As LongiOrder As Long#End IfEnd TypePublic Enum LVCOLUMN_maskLVCF_FMT = &H1LVCF_WIDTH = &H2LVCF_TEXT = &H4LVCF_SUBITEM = &H8#If (WIN32_IE >= &H300) ThenLVCF_IMAGE = &H10LVCF_ORDER = &H20#End IfEnd EnumPublic Enum LVCOLUMN_fmtLVCFMT_LEFT = &H0LVCFMT_RIGHT = &H1LVCFMT_CENTER = &H2LVCFMT_JUSTIFYMASK = &H3#If (WIN32_IE >= &H300) ThenLVCFMT_IMAGE = &H800LVCFMT_BITMAP_ON_RIGHT = &H1000LVCFMT_COL_HAS_IMAGES = &H8000&#End IfEnd EnumPublic Enum LVM_SETCOLUMNWIDTH_lParamLVSCW_AUTOSIZE = -1LVSCW_AUTOSIZE_USEHEADER = -2End Enum#If (WIN32_IE >= &H300) Then' // these flags only apply to LVS_OWNERDATA listviews in report or list modePublic Enum LVM_SETITEMCOUNT_lParamLVSICF_NOINVALIDATEALL = &H1LVSICF_NOSCROLL = &H2End Enum#End If#If (WIN32_IE >= &H300) ThenPublic Enum LVM_SETEXTENDEDLISTVIEWSTYLE_lParamLVS_EX_GRIDLINES = &H1LVS_EX_SUBITEMIMAGES = &H2LVS_EX_CHECKBOXES = &H4LVS_EX_TRACKSELECT = &H8LVS_EX_HEADERDRAGDROP = &H10LVS_EX_FULLROWSELECT = &H20 ' // applies to report mode onlyLVS_EX_ONECLICKACTIVATE = &H40LVS_EX_TWOCLICKACTIVATE = &H80#If (WIN32_IE >= &H400) ThenLVS_EX_FLATSB = &H100LVS_EX_REGIONAL = &H200LVS_EX_INFOTIP = &H400 ' listview does InfoTips for youLVS_EX_UNDERLINEHOT = &H800LVS_EX_UNDERLINECOLD = &H1000LVS_EX_MULTIWORKAREAS = &H2000LVS_EX_TRANSPARENTBKGND = &H400000#End If ' // WIN32_IE >= &H400End Enum#End If ' // WIN32_IE >= &H300#If (WIN32_IE >= &H400) ThenPublic Type LVBKIMAGEulFlags As LVBKIMAGE_ulFlagshbm As LongpszImage As Long ' if String, must be pre-allocatedcchImageMax As LongxOffsetPercent As LongyOffsetPercent As LongEnd TypePublic Enum LVBKIMAGE_ulFlagsLVBKIF_SOURCE_NONE = &H0LVBKIF_SOURCE_HBITMAP = &H1LVBKIF_SOURCE_URL = &H2LVBKIF_SOURCE_MASK = &H3LVBKIF_STYLE_NORMAL = &H0LVBKIF_STYLE_TILE = &H10LVBKIF_STYLE_MASK = &H10End Enum#End If ' // WIN32_IE >= &H400' ============================================' NotificationsPublic Enum LVNotificationsLVN_FIRST = -100& ' &HFFFFFF9C ' (0U-100U)LVN_LAST = -199& ' &HFFFFFF39 ' (0U-199U)' lParam points to:LVN_ITEMCHANGING = (LVN_FIRST - 0) ' NMLISTVIEW, ?, rtn T/FLVN_ITEMCHANGED = (LVN_FIRST - 1) ' NMLISTVIEW, ?LVN_INSERTITEM = (LVN_FIRST - 2) ' NMLISTVIEW, iItemLVN_DELETEITEM = (LVN_FIRST - 3) ' NMLISTVIEW, iItemLVN_DELETEALLITEMS = (LVN_FIRST - 4) ' NMLISTVIEW, iItem = -1, rtn T/FLVN_COLUMNCLICK = (LVN_FIRST - 8) ' NMLISTVIEW, iItem = -1, iSubItem = columnLVN_BEGINDRAG = (LVN_FIRST - 9) ' NMLISTVIEW, iItemLVN_BEGINRDRAG = (LVN_FIRST - 11) ' NMLISTVIEW, iItem#If (WIN32_IE >= &H300) ThenLVN_ODCACHEHINT = (LVN_FIRST - 13) ' NMLVCACHEHINTLVN_ITEMACTIVATE = (LVN_FIRST - 14) ' v4.70 = NMHDR, v4.71 = NMITEMACTIVATELVN_ODSTATECHANGED = (LVN_FIRST - 15) ' NMLVODSTATECHANGE, rtn T/F#End If ' // WIN32_IE >= &H300#If (WIN32_IE >= &H400) ThenLVN_HOTTRACK = (LVN_FIRST - 21) ' NMLISTVIEW, see docs, rtn T/F#End If#If UNICODE ThenLVN_BEGINLABELEDIT = (LVN_FIRST - 75)LVN_ENDLABELEDIT = (LVN_FIRST - 76)LVN_GETDISPINFO = (LVN_FIRST - 77)LVN_SETDISPINFO = (LVN_FIRST - 78)#If (WIN32_IE >= &H300) ThenLVN_ODFINDITEM = (LVN_FIRST - 79) ' NMLVFINDITEM#End If ' (WIN32_IE >= &H300)#If (WIN32_IE >= &H400) ThenLVN_GETINFOTIP = (LVN_FIRST - 58) ' NMLVGETINFOTIP#End If ' (WIN32_IE >= &H400)#ElseLVN_BEGINLABELEDIT = (LVN_FIRST - 5) ' NMLVDISPINFO, iItem, rtn T/FLVN_ENDLABELEDIT = (LVN_FIRST - 6) ' NMLVDISPINFO, see docsLVN_GETDISPINFO = (LVN_FIRST - 50) ' NMLVDISPINFO, see docsLVN_SETDISPINFO = (LVN_FIRST - 51) ' NMLVDISPINFO, see docs#If (WIN32_IE >= &H300) ThenLVN_ODFINDITEM = (LVN_FIRST - 52) ' NMLVFINDITEM#End If ' (WIN32_IE >= &H300)#If (WIN32_IE >= &H400) ThenLVN_GETINFOTIP = (LVN_FIRST - 57) ' NMLVGETINFOTIP#End If ' (WIN32_IE >= &H400)#End If ' UNICODELVN_KEYDOWN = (LVN_FIRST - 55) ' NMLVKEYDOWN#If (WIN32_IE >= &H300) ThenLVN_MARQUEEBEGIN = (LVN_FIRST - 56) ' NMLISTVIEW, rtn T/F#End IfEnd Enum ' LVNotificationsPublic Const CDDS_PREPAINT& = &H1Public Const CDDS_POSTPAINT& = &H2Public Const CDDS_PREERASE& = &H3Public Const CDDS_POSTERASE& = &H4Public Const CDDS_ITEM& = &H10000Public Const CDDS_ITEMPREPAINT& = CDDS_ITEM Or CDDS_PREPAINTPublic Const CDDS_ITEMPOSTPAINT& = CDDS_ITEM Or CDDS_POSTPAINTPublic Const CDDS_ITEMPREERASE& = CDDS_ITEM Or CDDS_PREERASEPublic Const CDDS_ITEMPOSTERASE& = CDDS_ITEM Or CDDS_POSTERASEPublic Const CDDS_SUBITEM& = &H20000Public Const CDRF_DODEFAULT& = &H0Public Const CDRF_NEWFONT& = &H2Public Const CDRF_SKIPDEFAULT& = &H4Public Const CDRF_NOTIFYPOSTPAINT& = &H10Public Const CDRF_NOTIFYITEMDRAW& = &H20Public Const CDRF_NOTIFYSUBITEMDRAW = &H20 ' flags are the same, we can distinguish by contextPublic Const CDRF_NOTIFYPOSTERASE& = &H40Public Const CDRF_NOTIFYITEMERASE& = &H80Public Type NMLISTVIEW ' was NM_LISTVIEWhdr As NMHDRiItem As LongiSubItem As LonguNewState As LVITEM_stateuOldState As LVITEM_stateuChanged As LVITEM_maskptAction As POINTAPIlParam As LongEnd Type#If (WIN32_IE >= &H400) Then'// NMITEMACTIVATE is used instead of NMLISTVIEW in IE >= 0x400'// therefore all the fields are the same except for extra uKeyFlags'// they are used to store key flags at the time of the single click with'// delayed activation - because by the time the timer goes off a user may'// not hold the keys (shift, ctrl) any morePublic Type NMITEMACTIVATEhdr As NMHDRiItem As LongiSubItem As LonguNewState As LonguOldState As LonguChanged As LongptAction As POINTAPIlParam As LonguKeyFlags As LongEnd Type'// key flags stored in uKeyFlagsPublic Enum NMITEMACTIVATE_uKeyFlagsLVKF_ALT = &H1LVKF_CONTROL = &H2LVKF_SHIFT = &H4End Enum#End If ' // WIN32_IE >= &H400#If (WIN32_IE >= &H300) ThenPublic Type NMCUSTOMDRAWhdr As NMHDRdwDrawStage As Longhdc As Longrc As RECTdwItemSpec As LonguItemState As LonglItemlParam As LongEnd TypePublic Type NMLVCUSTOMDRAWnmcd As NMCUSTOMDRAWclrText As LongclrTextBk As Long#If (WIN32_IE >= &H400) TheniSubItem As Long#End If ' // WIN32_IE >= &H400End TypePublic Type NMLVCACHEHINThdr As NMHDRiFrom As LongiTo As LongEnd TypePublic Type NMLVFINDITEM ' was NM_LVFINDITEMhdr As NMHDRiStart As Longlvfi As LVFINDINFOEnd TypePublic Type NMODSTATECHANGE ' was NM_ODSTATECHANGEhdr As NMHDRiFrom As LongiTo As LonguNewState As LonguOldState As LongEnd Type#End If ' // WIN32_IE >= &H300Public Type NMLVDISPINFO ' was LV_DISPINFOhdr As NMHDRitem As LVITEMEnd TypePublic Type NMLVKEYDOWN ' was LV_KEYDOWNhdr As NMHDRwVKey As Integer ' can't be KeyCodeConstants, enums are Longs!flags As Long ' Always zero.End Type#If (WIN32_IE >= &H400) ThenPublic Type NMLVGETINFOTIPhdr As NMHDRdwFlags As LongpszText As Long ' if String, must be pre-allocatedcchTextMax As LongiItem As LongiSubItem As LonglParam As LongEnd TypePrivate Type NMLVGETINFOTIP_NOSTRINGhdr As NMHDRdwFlags As LongpszText As LongcchTextMax As LongiItem As LongiSubItem As LonglParam As LongEnd TypePublic Const NM_FIRST As Long = 0Public Const NM_CUSTOMDRAW As Long = (NM_FIRST - 12)Public Const NM_CLICK As Long = (NM_FIRST - 2)Public Const NM_HOVER As Long = (NM_FIRST - 13)Public Type LV_DISPINFOhdr As NMHDRitem As LVITEMEnd Type' // NMLVGETINFOTIPA.dwFlag values ("A" ?)Public Const LVGIT_UNFOLDED = &H1#End If ' // WIN32_IE >= &H400Public Function ListView_GetBkColor(hwnd As Long) As LongListView_GetBkColor = SendMessage(hwnd, LVM_GETBKCOLOR, 0, 0)End FunctionPublic Function ListView_SetBkColor(hwnd As Long, clrBk As Long) As BooleanListView_SetBkColor = SendMessage(hwnd, LVM_SETBKCOLOR, 0, ByVal clrBk)End FunctionPublic Function ListView_GetImageList(hwnd As Long, iImageList As LVSIL_Flags) As LongListView_GetImageList = SendMessage(hwnd, LVM_GETIMAGELIST, ByVal iImageList, 0)End FunctionPublic Function ListView_SetImageList(hwnd As Long, himl As Long, iImageList As Long) As LongListView_SetImageList = SendMessage(hwnd, LVM_SETIMAGELIST, ByVal iImageList, ByVal himl)End FunctionPublic Function ListView_GetItemCount(hwnd As Long) As LongListView_GetItemCount = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0)End FunctionPublic Function ListView_GetItem(hwnd As Long, pitem As LVITEM) As BooleanListView_GetItem = SendMessage(hwnd, LVM_GETITEM, 0, pitem)End FunctionPublic Function ListView_SetItem(hwnd As Long, pitem As LVITEM) As BooleanListView_SetItem = SendMessage(hwnd, LVM_SETITEM, 0&, pitem)End FunctionPublic Function ListView_InsertItem(hwnd As Long, pitem As LVITEM) As LongListView_InsertItem = SendMessage(hwnd, LVM_INSERTITEM, 0, pitem)End FunctionPublic Function ListView_DeleteItem(hwnd As Long, i As Long) As BooleanListView_DeleteItem = SendMessage(hwnd, LVM_DELETEITEM, ByVal i, 0)End FunctionPublic Function ListView_DeleteAllItems(hwnd As Long) As BooleanListView_DeleteAllItems = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0)End FunctionPublic Function ListView_GetCallbackMask(hwnd As Long) As Long ' LVStylesListView_GetCallbackMask = SendMessage(hwnd, LVM_GETCALLBACKMASK, 0, 0)End FunctionPublic Function ListView_SetCallbackMask(hwnd As Long, mask As LVStyles) As BooleanListView_SetCallbackMask = SendMessage(hwnd, LVM_SETCALLBACKMASK, ByVal mask, 0)End FunctionPublic Function ListView_GetNextItem(hwnd As Long, i As Long, flags As LVNI_Flags) As LongListView_GetNextItem = SendMessage(hwnd, LVM_GETNEXTITEM, ByVal i, ByVal MAKELPARAM(flags, 0))End FunctionPublic Function ListView_FindItem(hwnd As Long, iStart, plvfi As LVFINDINFO) As LongListView_FindItem = SendMessage(hwnd, LVM_FINDITEM, ByVal iStart, plvfi)End FunctionPublic Function ListView_GetItemRect(hwnd As Long, i As Long, prc As RECT, code As LVIR_Flags) As Booleanprc.Left = codeListView_GetItemRect = SendMessage(hwnd, LVM_GETITEMRECT, ByVal i, prc)End FunctionPublic Function ListView_SetItemPosition(hwndLV As Long, i As Long, X As Long, Y As Long) As BooleanListView_SetItemPosition = SendMessage(hwndLV, LVM_SETITEMPOSITION, ByVal i, ByVal MAKELPARAM(X, Y))End FunctionPublic Function ListView_GetItemPosition(hwndLV As Long, i As Long, ppt As Point) As BooleanListView_GetItemPosition = SendMessage(hwndLV, LVM_GETITEMPOSITION, ByVal i, ppt)End FunctionPublic Function ListView_GetStringWidth(hwndLV As Long, psz As String) As LongListView_GetStringWidth = SendMessage(hwndLV, LVM_GETSTRINGWIDTH, 0, ByVal psz)End FunctionPublic Function ListView_HitTest(hwndLV As Long, pinfo As LVHITTESTINFO) As LongListView_HitTest = SendMessage(hwndLV, LVM_HITTEST, 0, pinfo)End FunctionPublic Function ListView_EnsureVisible(hwndLV As Long, i As Long, fPartialOK As Boolean) As BooleanListView_EnsureVisible = SendMessage(hwndLV, LVM_ENSUREVISIBLE, ByVal i, ByVal MAKELPARAM(Abs(fPartialOK), 0))End FunctionPublic Function ListView_Scroll(hwndLV As Long, dx As Long, dy As Long) As BooleanListView_Scroll = SendMessage(hwndLV, LVM_SCROLL, ByVal dx, ByVal dy)End FunctionPublic Function ListView_RedrawItems(hwndLV As Long, iFirst, iLast) As BooleanListView_RedrawItems = SendMessage(hwndLV, LVM_REDRAWITEMS, ByVal iFirst, ByVal iLast)End FunctionPublic Function ListView_Arrange(hwndLV As Long, code As LVA_Flags) As BooleanListView_Arrange = SendMessage(hwndLV, LVM_ARRANGE, ByVal code, 0)End FunctionPublic Function ListView_EditLabel(hwndLV As Long, i As Long) As LongListView_EditLabel = SendMessage(hwndLV, LVM_EDITLABEL, ByVal i, 0)End FunctionPublic Function ListView_GetEditControl(hwndLV As Long) As LongListView_GetEditControl = SendMessage(hwndLV, LVM_GETEDITCONTROL, 0, 0)End FunctionPublic Function ListView_GetColumn(hwnd As Long, iCol As Long, pcol As LVCOLUMN) As BooleanListView_GetColumn = SendMessage(hwnd, LVM_GETCOLUMN, ByVal iCol, pcol)End FunctionPublic Function ListView_SetColumn(hwnd As Long, iCol As Long, pcol As LVCOLUMN) As BooleanListView_SetColumn = SendMessage(hwnd, LVM_SETCOLUMN, ByVal iCol, pcol)End FunctionPublic Function ListView_InsertColumn(hwnd As Long, iCol As Long, pcol As LVCOLUMN) As LongListView_InsertColumn = SendMessage(hwnd, LVM_INSERTCOLUMN, ByVal iCol, pcol)End FunctionPublic Function ListView_DeleteColumn(hwnd As Long, iCol As Long) As BooleanListView_DeleteColumn = SendMessage(hwnd, LVM_DELETECOLUMN, ByVal iCol, 0)End FunctionPublic Function ListView_GetColumnWidth(hwnd As Long, iCol As Long) As LongListView_GetColumnWidth = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, ByVal iCol, 0)End FunctionPublic Function ListView_SetColumnWidth(hwnd As Long, iCol As Long, cx As Long) As BooleanListView_SetColumnWidth = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, ByVal iCol, ByVal MAKELPARAM(cx, 0))End Function#If (WIN32_IE >= &H300) ThenPublic Function ListView_GetHeader(hwnd As Long) As LongListView_GetHeader = SendMessage(hwnd, LVM_GETHEADER, 0, 0)End Function'#End IfPublic Function ListView_CreateDragImage(hwnd As Long, i As Long, lpptUpLeft As POINTAPI) As LongListView_CreateDragImage = SendMessage(hwnd, LVM_CREATEDRAGIMAGE, ByVal i, lpptUpLeft)End FunctionPublic Function ListView_GetViewRect(hwnd As Long, prc As RECT) As BooleanListView_GetViewRect = SendMessage(hwnd, LVM_GETVIEWRECT, 0, prc)End FunctionPublic Function ListView_GetTextColor(hwnd As Long) As LongListView_GetTextColor = SendMessage(hwnd, LVM_GETTEXTCOLOR, 0, 0)End FunctionPublic Function ListView_SetTextColor(hwnd As Long, clrText As Long) As BooleanListView_SetTextColor = SendMessage(hwnd, LVM_SETTEXTCOLOR, 0, ByVal clrText)End FunctionPublic Function ListView_GetTextBkColor(hwnd As Long) As LongListView_GetTextBkColor = SendMessage(hwnd, LVM_GETTEXTBKCOLOR, 0, 0)End FunctionPublic Function ListView_SetTextBkColor(hwnd As Long, clrTextBk As Long) As BooleanListView_SetTextBkColor = SendMessage(hwnd, LVM_SETTEXTBKCOLOR, 0, ByVal clrTextBk)End FunctionPublic Function ListView_GetTopIndex(hwndLV As Long) As LongListView_GetTopIndex = SendMessage(hwndLV, LVM_GETTOPINDEX, 0, 0)End FunctionPublic Function ListView_GetCountPerPage(hwndLV As Long) As LongListView_GetCountPerPage = SendMessage(hwndLV, LVM_GETCOUNTPERPAGE, 0, 0)End FunctionPublic Function ListView_GetOrigin(hwndLV As Long, ppt As POINTAPI) As BooleanListView_GetOrigin = SendMessage(hwndLV, LVM_GETORIGIN, 0, ppt)End FunctionPublic Function ListView_Update(hwndLV As Long, i As Long) As BooleanListView_Update = SendMessage(hwndLV, LVM_UPDATE, ByVal i, 0)End FunctionPublic Function ListView_SetItemState(hwndLV As Long, i As Long, state As LVITEM_state, mask As LVITEM_state) As BooleanDim lvI As LVITEMlvI.state = statelvI.stateMask = maskListView_SetItemState = SendMessage(hwndLV, LVM_SETITEMSTATE, ByVal i, lvI)End FunctionPublic Function ListView_GetItemState(hwndLV As Long, i As Long, mask As LVITEM_state) As Long' LVITEM_stateListView_GetItemState = SendMessage(hwndLV, LVM_GETITEMSTATE, ByVal i, ByVal mask)End Function#If (WIN32_IE >= &H300) ThenPublic Function ListView_GetCheckState(hwndLV As Long, iIndex As Long) As Long ' updatedDim dwState As LongdwState = 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 IfPublic Sub ListView_GetItemText(hwndLV As Long, i As Long, iSubItem As Long, _pszText As Long, cchTextMax As Long)Dim lvI As LVITEMlvI.iSubItem = iSubItemlvI.cchTextMax = cchTextMaxlvI.pszText = pszTextSendMessage hwndLV, LVM_GETITEMTEXT, ByVal i, lvIpszText = lvI.pszText ' fills pszText w/ pointerEnd SubPublic Function ListView_GetItemIndent(hwndLV As Long, i As Long) As LongDim lvI As LVITEMlvI.iItem = i - 1lvI.mask = LVIF_INDENT Or LVIF_STATE'SendMessage hwndLV, LVM_GETITEM, 0&, lvIIf ListView_GetItem(hwndLV, lvI) ThenListView_GetItemIndent = lvI.iIndentElseListView_GetItemIndent = -1End IfEnd FunctionPublic Sub ListView_SetItemIndent(hwndLV As Long, i As Long, indent As Long)Dim lvI As LVITEMlvI.iItem = i - 1lvI.mask = LVIF_INDENT Or LVIF_STATEwin.SendMessage hwndLV, LVM_GETITEM, ByVal 0&, lvIlvI.iIndent = indent'win.SendMessage hwndLV, LVM_SETITEM, 0&, lvIListView_SetItem hwndLV, lvIEnd SubPublic Sub ListView_SetItemText(hwndLV As Long, i As Long, iSubItem As Long, pszText As String)Dim lvI As LVITEMlvI.iSubItem = iSubItemlvI.pszText = pszTextSendMessage hwndLV, LVM_SETITEMTEXT, ByVal i, lvIEnd SubPublic Sub ListView_SetItemCount(hwndLV As Long, cItems As Long)SendMessage hwndLV, LVM_SETITEMCOUNT, ByVal cItems, 0End Sub#If (WIN32_IE >= &H300) ThenPublic Sub ListView_SetItemCountEx(hwndLV As Long, cItems As Long, dwFlags As Long)SendMessage hwndLV, LVM_SETITEMCOUNT, ByVal cItems, ByVal dwFlagsEnd Sub'#End IfPublic Function ListView_SortItems(hwndLV As Long, pfnCompare As Long, lParamSort As Long) As BooleanListView_SortItems = SendMessage(hwndLV, LVM_SORTITEMS, ByVal lParamSort, ByVal pfnCompare)End FunctionPublic Sub ListView_SetItemPosition32(hwndLV As Long, i As Long, X As Long, Y As Long, Optional isTwips As Boolean)Dim ptNewPos As POINTAPIIf isTwips = True ThenptNewPos.X = X \ Screen.TwipsPerPixelXptNewPos.Y = Y \ Screen.TwipsPerPixelYElseptNewPos.X = XptNewPos.Y = YEnd IfSendMessage hwndLV, LVM_SETITEMPOSITION32, ByVal i, ptNewPosEnd SubPublic Function ListView_GetSelectedCount(hwndLV As Long) As LongListView_GetSelectedCount = SendMessage(hwndLV, LVM_GETSELECTEDCOUNT, 0, 0)End FunctionPublic Function ListView_GetItemSpacing(hwndLV As Long, fSmall As Boolean) As LongListView_GetItemSpacing = SendMessage(hwndLV, LVM_GETITEMSPACING, ByVal fSmall, 0)End FunctionPublic Function ListView_GetISearchString(hwndLV As Long, lpsz As String) As BooleanListView_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 rectanglePublic Function ListView_GetSelectedItem(hwndLV As Long) As LongListView_GetSelectedItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL Or _LVNI_FOCUSED Or _LVNI_SELECTED)End Function' Selects the specified item and gives it the focus rectangle.' does not de-select any currently selected itemsPublic Function ListView_SetSelectedItem(hwndLV As Long, i As Long) As BooleanListView_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 BooleanListView_SelectAll = ListView_SetItemState(hwndLV, -1, LVIS_SELECTED, LVIS_SELECTED)End Function' ==============================================================#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 LongListView_SetIconSpacing = SendMessage(hwndLV, LVM_SETICONSPACING, 0, ByVal MAKELONG(cx, cy))End FunctionPublic Function ListView_SetExtendedListViewStyle(hwndLV As Long, dw As Long) As LongListView_SetExtendedListViewStyle = SendMessage(hwndLV, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal dw)End FunctionPublic Function ListView_GetExtendedListViewStyle(hwndLV As Long) As LongListView_GetExtendedListViewStyle = SendMessage(hwndLV, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)End FunctionPublic Function ListView_GetSubItemRect(hwnd As Long, iItem As Long, iSubItem As Long, _code As Long, prc As RECT) As Booleanprc.Top = iSubItemprc.Left = codeListView_GetSubItemRect = SendMessage(hwnd, LVM_GETSUBITEMRECT, ByVal iItem, prc)End FunctionPublic Function ListView_SubItemHitTest(hwnd As Long, plvhti As LVHITTESTINFO) As LongListView_SubItemHitTest = SendMessage(hwnd, LVM_SUBITEMHITTEST, 0, plvhti)End FunctionPublic Function ListView_SetColumnOrderArray(hwnd As Long, iCount As Long, lpiArray As Long) As BooleanListView_SetColumnOrderArray = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, ByVal iCount, lpiArray)End FunctionPublic Function ListView_GetColumnOrderArray(hwnd As Long, iCount As Long, lpiArray As Long) As BooleanListView_GetColumnOrderArray = SendMessage(hwnd, LVM_GETCOLUMNORDERARRAY, ByVal iCount, lpiArray)End FunctionPublic Function ListView_SetHotItem(hwnd As Long, i As Long) As LongListView_SetHotItem = SendMessage(hwnd, LVM_SETHOTITEM, ByVal i, 0)End FunctionPublic Function ListView_GetHotItem(hwnd As Long) As LongListView_GetHotItem = SendMessage(hwnd, LVM_GETHOTITEM, 0, 0)End FunctionPublic Function ListView_SetHotCursor(hwnd As Long, hcur As Long) As LongListView_SetHotCursor = SendMessage(hwnd, LVM_SETHOTCURSOR, 0, ByVal hcur)End FunctionPublic Function ListView_GetHotCursor(hwnd As Long) As LongListView_GetHotCursor = SendMessage(hwnd, LVM_GETHOTCURSOR, 0, 0)End FunctionPublic Function ListView_ApproximateViewRect(hwnd As Long, iWidth As Long, _iHeight As Long, iCount As Long) As LongListView_ApproximateViewRect = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, ByVal iCount, ByVal MAKELPARAM(iWidth, iHeight))End Function'#End If ' ' WIN32_IE >= &H300'' ==============================================================#If (WIN32_IE >= &H400) ThenPublic Function ListView_SetUnicodeFormat(hwnd As Long, fUnicode As Boolean) As BooleanListView_SetUnicodeFormat = SendMessage(hwnd, LVM_SETUNICODEFORMAT, ByVal fUnicode, 0)End FunctionPublic Function ListView_GetUnicodeFormat(hwnd As Long) As BooleanListView_GetUnicodeFormat = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0)End FunctionPublic Function ListView_SetExtendedListViewStyleEx(hwndLV As Long, dwMask As Long, dw As Long) As LongListView_SetExtendedListViewStyleEx = SendMessage(hwndLV, LVM_SETEXTENDEDLISTVIEWSTYLE, ByVal dwMask, ByVal dw)End FunctionPublic Function ListView_SetWorkAreas(hwnd As Long, nWorkAreas As Long, prc() As RECT) As BooleanListView_SetWorkAreas = SendMessage(hwnd, LVM_SETWORKAREAS, ByVal nWorkAreas, prc(0))End FunctionPublic Function ListView_GetWorkAreas(hwnd As Long, nWorkAreas, prc() As RECT) As BooleanListView_GetWorkAreas = SendMessage(hwnd, LVM_GETWORKAREAS, ByVal nWorkAreas, prc(0))End FunctionPublic Function ListView_GetNumberOfWorkAreas(hwnd As Long, pnWorkAreas As Long) As BooleanListView_GetNumberOfWorkAreas = SendMessage(hwnd, LVM_GETNUMBEROFWORKAREAS, 0, pnWorkAreas)End FunctionPublic Function ListView_GetSelectionMark(hwnd As Long) As LongListView_GetSelectionMark = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0)End FunctionPublic Function ListView_SetSelectionMark(hwnd As Long, i As Long) As LongListView_SetSelectionMark = SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, ByVal i)End FunctionPublic Function ListView_SetHoverTime(hwndLV As Long, dwHoverTimeMs As Long) As LongListView_SetHoverTime = SendMessage(hwndLV, LVM_SETHOVERTIME, 0, ByVal dwHoverTimeMs)End FunctionPublic Function ListView_GetHoverTime(hwndLV As Long) As LongListView_GetHoverTime = SendMessage(hwndLV, LVM_GETHOVERTIME, 0, 0)End FunctionPublic Function ListView_SetToolTips(hwndLV As Long, hwndNewHwnd As Long) As LongListView_SetToolTips = SendMessage(hwndLV, LVM_SETTOOLTIPS, ByVal hwndNewHwnd, 0)End FunctionPublic Function ListView_GetToolTips(hwndLV As Long) As LongListView_GetToolTips = SendMessage(hwndLV, LVM_GETTOOLTIPS, 0, 0)End FunctionPublic Function ListView_SetBkImage(hwnd As Long, plvbki As LVBKIMAGE) As BooleanListView_SetBkImage = SendMessage(hwnd, LVM_SETBKIMAGE, 0, plvbki)End FunctionPublic Function ListView_GetBkImage(hwnd As Long, plvbki As LVBKIMAGE) As BooleanListView_GetBkImage = SendMessage(hwnd, LVM_GETBKIMAGE, 0, plvbki)End Function#End If ' WIN32_IE >= &H400Public Function ListView_HasScrollbar(lvw As ListView) As BooleanDim perPage As LongperPage = SendMessage(lvw.hwnd, LVM_GETCOUNTPERPAGE, 0&, 0&)ListView_HasScrollbar = (lvw.ListItems.Count > perPage)End FunctionPublic Function MAKELONG(wLow As Long, wHigh As Long) As LongMAKELONG = LoWord(wLow) Or (&H10000 * LoWord(wHigh))End FunctionPrivate Function MAKELPARAM(wLow As Long, wHigh As Long) As LongMAKELPARAM = MAKELONG(wLow, wHigh)End FunctionPublic Function LoWord(ByVal dwValue As Long) As Integer' Returns the low 16-bit integer from a 32-bit long integerCopyMemory LoWord, dwValue, 2&End FunctionPublic Function HiWord(ByVal nValue&) As Integer' returns the high 16-bit integer from a 32-bit long integerCopyMemory HiWord, ByVal VarPtr(nValue) + 2, 2&End Function