Treeview的API全集(1)-----www.mvps.org
Public Type POINTAPI ' pt
x As Long
y As Long
End Type
Public Type RECT ' rct
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Enum CBoolean
CFalse = 0
CTrue = 1
End Enum
' ================================================================
' Generic WM_NOTIFY notification messages.
' The lParam of all messages points to the NMHDR struct unless noted.
Public Enum CCNotifications
NM_FIRST = -0& ' (0U- 0U) ' generic to all controls
NM_LAST = -99& ' (0U- 99U)
NM_OUTOFMEMORY = (NM_FIRST - 1)
NM_CLICK = (NM_FIRST - 2)
NM_DBLCLK = (NM_FIRST - 3)
NM_RETURN = (NM_FIRST - 4)
NM_RCLICK = (NM_FIRST - 5)
NM_RDBLCLK = (NM_FIRST - 6)
NM_SETFOCUS = (NM_FIRST - 7)
NM_KILLFOCUS = (NM_FIRST - 8)
#If (Win32_IE >= &H300) Then
NM_CUSTOMDRAW = (NM_FIRST - 12)
NM_HOVER = (NM_FIRST - 13)
#End If ' 300
#If (Win32_IE >= &H400) Then
NM_NCHITTEST = (NM_FIRST - 14) ' lParam = NMMOUSE struct
NM_KEYDOWN = (NM_FIRST - 15) ' lParam = NMKEY struct
NM_RELEASEDCAPTURE = (NM_FIRST - 16)
NM_SETCURSOR = (NM_FIRST - 17) ' lParam = NMMOUSE struct
NM_CHAR = (NM_FIRST - 18) ' lParam = NMCHAR struct
#End If '400
End Enum
' ================================================================
' Generic WM_NOTIFY notification structures
' The NMHDR structure contains information about a notification message. The pointer
' to this structure is specified as the lParam member of the WM_NOTIFY message.
Public Type NMHDR
hwndFrom As Long ' Window handle of control sending message
idFrom As Long ' Identifier of control sending message
code As Long ' Specifies the notification code
End Type
#If (Win32_IE >= &H400) Then
Public Type NMMOUSE
hdr As NMHDR
dwItemSpec As Long
dwItemData As Long
pt As POINTAPI
dwHitInfo As Long ' any specifics about where on the item or control the mouse is
End Type
' Generic structure to request an object of a specific type.
Public Type NMOBJECTNOTIFY
hdr As NMHDR
iItem As Long
piid As Long
pObject As Long
hResult As Long
dwFlags As Long ' control specific flags (hints as to where in iItem it hit)
End Type
' Generic structure for a key
Public Type NMKEY
hdr As NMHDR
nVKey As Long
uFlags As Long
End Type
' Generic structure for a character
Public Type NMCHAR
hdr As NMHDR
ch As Long
dwItemPrev As Long ' Item previously selected
dwItemNext As Long ' Item to be selected
End Type
'
#End If ' WIN32_IE >= &H400
' ==============================================================
' Shared common control messages
#If (Win32_IE >= &H400) Then
Public Const CCM_FIRST = &H2000
Public Const CCM_SETBKCOLOR = (CCM_FIRST + 1) ' lParam is bkColor
Public Type COLORSCHEME
dwSize As Long
clrBtnHighlight As Long ' highlight color, COLORREF
clrBtnShadow As Long ' shadow color, COLORREF
End Type
Public Const CCM_SETCOLORSCHEME = (CCM_FIRST + 2) ' lParam is color scheme
Public Const CCM_GETCOLORSCHEME = (CCM_FIRST + 3) ' fills in COLORSCHEME pointed to by lParam
Public Const CCM_GETDROPTARGET = (CCM_FIRST + 4)
Public Const CCM_SETUNICODEFORMAT = (CCM_FIRST + 5)
Public Const CCM_GETUNICODEFORMAT = (CCM_FIRST + 6)
' For tooltips
Public Const INFOTIPSIZE = 1024
#End If ' WIN32_IE >= &H400
' ================================================================
' Treeview control definitions
' Classname
Public Const WC_TREEVIEW = "SysTreeView32"
' Treeview styles
Public Enum TVStyles
TVS_HASBUTTONS = &H1
TVS_HASLINES = &H2
TVS_LINESATROOT = &H4
TVS_EDITLABELS = &H8
TVS_DISABLEDRAGDROP = &H10
TVS_SHOWSELALWAYS = &H20
TVS_RTLREADING = &H40
#If (Win32_IE >= &H300) Then
TVS_NOTOOLTIPS = &H80
TVS_CHECKBOXES = &H100
TVS_TRACKSELECT = &H200
#If (Win32_IE >= &H400) Then
TVS_SINGLEEXPAND = &H400
TVS_INFOTIP = &H800
TVS_FULLROWSELECT = &H1000
TVS_NOSCROLL = &H2000
TVS_NONEVENHEIGHT = &H4000
#End If ' 400
#End If ' 300
TVS_SHAREDIMAGELISTS = &H0
TVS_PRIVATEIMAGELISTS = &H400
End Enum
'typedef struct _TREEITEM FAR* HTREEITEM;
' ================================================================
' TVITEM struct
Public Type TVITEM ' was TV_ITEM
mask As TVITEM_mask
hItem As Long
state As TVITEM_state
stateMask As Long
pszText As Long ' pointer
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
End Type
#If (Win32_IE >= &H400) Then
' only used for Get and Set messages (not for notifications)
Public Type TVITEMEX
mask As TVITEM_mask
hItem As Long
state As TVITEM_state
stateMask As Long
pszText As Long ' pointer
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
iIntegral As Long
End Type
#End If
Public Enum TVITEM_mask
TVIF_TEXT = &H1
TVIF_IMAGE = &H2
TVIF_PARAM = &H4
TVIF_STATE = &H8
TVIF_HANDLE = &H10
TVIF_SELECTEDIMAGE = &H20
TVIF_CHILDREN = &H40
#If (Win32_IE >= &H400) Then
TVIF_INTEGRAL = &H80
#End If
TVIF_DI_SETITEM = &H1000 ' Notification
End Enum
Public Enum TVITEM_state
TVIS_SELECTED = &H2
TVIS_CUT = &H4
TVIS_DROPHILITED = &H8
TVIS_BOLD = &H10
TVIS_EXPANDED = &H20
TVIS_EXPANDEDONCE = &H40
#If (Win32_IE >= &H300) Then
TVIS_EXPANDPARTIAL = &H80
#End If
TVIS_OVERLAYMASK = &HF00
TVIS_STATEIMAGEMASK = &HF000
TVIS_USERMASK = &HF000
End Enum
' TVITEM(EX).pszText
Public Const LPSTR_TEXTCALLBACK = (-1)
' TVITEM.iImage, TVITEM.iSelectedImage
Public Const I_IMAGECALLBACK = (-1)
' TVITEM.cChildren
Public Const I_CHILDRENCALLBACK = (-1)
' ================================================================
' Treeview messages
Public Enum TVHandles
TVI_ROOT = &HFFFF0000
TVI_FIRST = &HFFFF0001
TVI_LAST = &HFFFF0002
TVI_SORT = &HFFFF0003
End Enum
Public Type TVINSERTSTRUCT ' was TV_INSERTSTRUCT
hParent As Long
hInsertAfter As Long
#If (Win32_IE >= &H400) Then
' Union
' {
' use larger of two structs
itemex As TVITEMEX
' TVITEM item;
' } DUMMYUNIONNAME;
#Else
item As TVITEM
#End If
End Type