📄 uclistview.ctl
字号:
Private Const NM_DBLCLK As Long = (NM_FIRST - 3)
Private Const NM_RETURN As Long = (NM_FIRST - 4)
Private Const NM_RCLICK As Long = (NM_FIRST - 5)
Private Const NM_RDBLCLK As Long = (NM_FIRST - 6)
Private Const NM_SETFOCUS As Long = (NM_FIRST - 7)
Private Const NM_KILLFOCUS As Long = (NM_FIRST - 8)
Private Const NM_CUSTOMDRAW As Long = (NM_FIRST - 12)
Private Const NM_HOVER As Long = (NM_FIRST - 13)
Private Const LVN_FIRST As Long = -100
Private Const LVN_ITEMCHANGING As Long = (LVN_FIRST - 0)
Private Const LVN_ITEMCHANGED As Long = (LVN_FIRST - 1)
Private Const LVN_INSERTITEM As Long = (LVN_FIRST - 2)
Private Const LVN_DELETEITEM As Long = (LVN_FIRST - 3)
Private Const LVN_DELETEALLITEMS As Long = (LVN_FIRST - 4)
Private Const LVN_BEGINLABELEDIT As Long = (LVN_FIRST - 5)
Private Const LVN_ENDLABELEDIT As Long = (LVN_FIRST - 6)
Private Const LVN_COLUMNCLICK As Long = (LVN_FIRST - 8)
Private Const LVN_BEGINDRAG As Long = (LVN_FIRST - 9)
Private Const LVN_BEGINRDRAG As Long = (LVN_FIRST - 11)
Private Const LVNI_ALL As Long = &H0
Private Const LVNI_FOCUSED As Long = &H1
Private Const LVNI_SELECTED As Long = &H2
Private Const LVNI_CUT As Long = &H4
Private Const LVNI_DROPHILITED As Long = &H8
Private Const LVNI_ABOVE As Long = &H100
Private Const LVNI_BELOW As Long = &H200
Private Const LVNI_TOLEFT As Long = &H400
Private Const LVNI_TORIGHT As Long = &H800
Private Const LVHT_NOWHERE As Long = &H1
Private Const LVHT_ONITEMICON As Long = &H2
Private Const LVHT_ONITEMLABEL As Long = &H4
Private Const LVHT_ONITEMSTATEICON As Long = &H8
Private Const LVHT_ONITEM As Long = (LVHT_ONITEMICON Or LVHT_ONITEMLABEL Or LVHT_ONITEMSTATEICON)
Private Const LVHT_ABOVE As Long = &H8
Private Const LVHT_BELOW As Long = &H10
Private Const LVHT_TORIGHT As Long = &H20
Private Const LVHT_TOLEFT As Long = &H40
Private Const HDN_FIRST As Long = -300
Private Const HDN_ITEMCHANGING As Long = (HDN_FIRST - 0)
Private Const HDN_ITEMCLICK As Long = (HDN_FIRST - 2)
Private Const HDN_ITEMDBLCLICK As Long = (HDN_FIRST - 3)
Private Const HDN_DIVIDERDBLCLICK As Long = (HDN_FIRST - 5)
Private Const HDN_BEGINTRACK As Long = (HDN_FIRST - 6)
Private Const HDN_ENDTRACK As Long = (HDN_FIRST - 7)
Private Const HDN_TRACK As Long = (HDN_FIRST - 8)
Private Const HDN_GETDISPINFO As Long = (HDN_FIRST - 9)
Private Const HDN_BEGINDRAG As Long = (HDN_FIRST - 10)
Private Const HDN_ENDDRAG As Long = (HDN_FIRST - 11)
Private Const HHT_NOWHERE As Long = &H1
Private Const HHT_ONHEADER As Long = &H2
Private Const HHT_ONDIVIDER As Long = &H4
Private Const HHT_ONDIVOPEN As Long = &H8
Private Const HHT_ABOVE As Long = &H100
Private Const HHT_BELOW As Long = &H200
Private Const HHT_TORIGHT As Long = &H400
Private Const HHT_TOLEFT As Long = &H800
Private Const HDI_WIDTH As Long = &H1
Private Const HDI_HEIGHT As Long = HDI_WIDTH
Private Const HDI_TEXT As Long = &H2
Private Const HDI_FORMAT As Long = &H4
Private Const HDI_LPARAM As Long = &H8
Private Const HDI_BITMAP As Long = &H10
Private Const HDI_IMAGE As Long = &H20
Private Const HDI_DI_SETITEM As Long = &H40
Private Const HDI_ORDER As Long = &H80
'= Custom draw ==========================================================================
Private Type NMCUSTOMDRAW
hdr As NMHDR
dwDrawStage As Long
hdc As Long
rc As RECT2
dwItemSpec As Long
uItemState As Long
lItemlParam As Long
End Type
Private Type NMLVCUSTOMDRAW
nmcd As NMCUSTOMDRAW
clrText As Long
clrTextBk As Long
iSubItem As Long
End Type
'- Custom draw paint stages
Private Const CDDS_PREPAINT As Long = &H1
Private Const CDDS_POSTPAINT As Long = &H2
Private Const CDDS_PREERASE As Long = &H3
Private Const CDDS_POSTERASE As Long = &H4
Private Const CDDS_ITEM As Long = &H10000
Private Const CDDS_SUBITEM As Long = &H20000
Private Const CDDS_ITEMPREPAINT As Long = (CDDS_ITEM Or CDDS_PREPAINT)
Private Const CDDS_ITEMPOSTPAINT As Long = (CDDS_ITEM Or CDDS_POSTPAINT)
Private Const CDDS_ITEMPREERASE As Long = (CDDS_ITEM Or CDDS_PREERASE)
Private Const CDDS_ITEMPOSTERASE As Long = (CDDS_ITEM Or CDDS_POSTERASE)
'- Custom draw Item states
Private Const CDIS_SELECTED As Long = &H1
Private Const CDIS_GRAYED As Long = &H2
Private Const CDIS_DISABLED As Long = &H4
Private Const CDIS_CHECKED As Long = &H8
Private Const CDIS_FOCUS As Long = &H10
Private Const CDIS_DEFAULT As Long = &H20
Private Const CDIS_HOT As Long = &H40
Private Const CDIS_MARKED As Long = &H80
Private Const CDIS_INDETERMINATE As Long = &H100
'- Custom draw return values
Private Const CDRF_DODEFAULT As Long = &H0
Private Const CDRF_NEWFONT As Long = &H2
Private Const CDRF_SKIPDEFAULT As Long = &H4
Private Const CDRF_NOTIFYPOSTPAINT As Long = &H10
Private Const CDRF_NOTIFYITEMDRAW As Long = &H20
Private Const CDRF_NOTIFYPOSTERASE As Long = &H40
Private Const CDRF_NOTIFYSUBITEMDRAW As Long = &H20
'= Image list ===========================================================================
Private Declare Function ImageList_Create Lib "Comctl32" (ByVal MinCx As Long, ByVal MinCy As Long, ByVal flags As Long, ByVal cInitial As Long, ByVal cGrow As Long) As Long
Private Declare Function ImageList_Add Lib "Comctl32" (ByVal hImageList As Long, ByVal hBitmap As Long, ByVal hBitmapMask As Long) As Long
Private Declare Function ImageList_SetBkColor Lib "Comctl32" (ByVal hImageList As Long, ByVal clrBk As Long) As Long
Private Declare Function ImageList_AddMasked Lib "Comctl32" (ByVal hImageList As Long, ByVal hbmImage As Long, ByVal crMask As Long) As Long
Private Declare Function ImageList_AddIcon Lib "Comctl32" (ByVal hImageList As Long, ByVal hIcon As Long) As Long
Private Declare Function ImageList_Destroy Lib "Comctl32" (ByVal hImageList As Long) As Long
Private Declare Function ImageList_Draw Lib "Comctl32" (ByVal hImageList As Long, ByVal lIndex As Long, ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal fStyle As Long) As Long
Private Const LVSIL_NORMAL As Long = 0
Private Const LVSIL_SMALL As Long = 1
Private Const LVSIL_STATE As Long = 2
Private Const ILD_NORMAL As Long = 0&
Private Const ILD_TRANSPARENT As Long = 1&
Private Const ILD_BLEND25 As Long = 2&
Private Const ILD_SELECTED As Long = 4&
Private Const ILD_FOCUS As Long = 4&
Private Const ILD_MASK As Long = &H10&
Private Const ILD_IMAGE As Long = &H20&
Private Const ILD_ROP As Long = &H40&
Private Const ILD_OVERLAYMASK As Long = 3840&
Private Const DST_COMPLEX As Long = &H0&
Private Const DST_TEXT As Long = &H1&
Private Const DST_PREFIXTEXT As Long = &H2&
Private Const DST_ICON As Long = &H3&
Private Const DST_BITMAP As Long = &H4&
Private Const DSS_NORMAL As Long = &H0&
Private Const DSS_UNION As Long = &H10&
Private Const DSS_DISABLED As Long = &H20&
Private Const DSS_MONO As Long = &H80&
Private Const DSS_RIGHT As Long = &H8000&
Private Const ILC_COLOR As Long = &H0
Private Const ILC_MASK As Long = &H1
Private Const ILC_COLOR4 As Long = &H4
Private Const ILC_COLOR8 As Long = &H8
Private Const ILC_COLOR16 As Long = &H10
Private Const ILC_COLOR24 As Long = &H18
Private Const ILC_COLOR32 As Long = &H20
'//
'-- Public enums.:
Public Enum eViewModeConstants
[vmIcon] = LVS_ICON
[vmSmallIcon] = LVS_SMALLICON
[vmList] = LVS_LIST
[vmDetails] = LVS_REPORT
End Enum
Public Enum eBorderStyleConstants
[bsNone] = 0
[bsThin] = 1
[bsThick] = 2
End Enum
Public Enum eColumnAlignConstants
[caLeft] = HDF_LEFT
[caRight] = HDF_RIGHT
[caCenter] = HDF_CENTER
End Enum
Public Enum eColumnAutosizeConstants
[caItem] = LVSCW_AUTOSIZE
[caHeader] = LVSCW_AUTOSIZE_USEHEADER
End Enum
Public Enum eCoincidenceConstants
[cWholeWord] = LVFI_STRING
[cPartial] = LVFI_PARTIAL
End Enum
Public Enum eStateConstants
[sSelected] = LVNI_SELECTED
[sFocused] = LVNI_FOCUSED
[sGhosted] = LVNI_CUT
End Enum
Public Enum eSortOrderConstants
[soDefault] = 0
[soAscending] = 1
[soDescending] = -1
End Enum
Public Enum eSortTypeConstants
[stString] = 0
[stStringSensitive] = 1
[stNumeric] = 2
[stDate] = 3
End Enum
'-- Property variables:
Private m_BorderStyle As eBorderStyleConstants
Private m_CheckBoxes As Boolean
Private m_EditLabels As Boolean
Private m_FullRowSelect As Boolean
Private m_GridLines As Boolean
Private m_HeaderDragDrop As Boolean
Private m_HeaderFixedWidth As Boolean
Private m_HeaderFlat As Boolean
Private m_HeaderHide As Boolean
Private m_HideSelection As Boolean
Private m_LabelTips As Boolean
Private m_MultiSelect As Boolean
Private m_OneClickActivate As Boolean
Private m_ScrollBarFlat As Boolean
Private m_SubItemImages As Boolean
Private m_TrackSelect As Boolean
Private m_UnderlineHot As Boolean
Private m_ViewMode As eViewModeConstants
'//
Private m_RaiseSubItemPrePaint As Boolean
'//
'-- Private constants:
Private Const WC_LISTVIEW As String = "SysListView32"
'-- Private variables:
Private m_hModShell32 As Long
Private m_bInitialized As Boolean
Private m_bFirstItem As Boolean
Private m_bTrack As Boolean
Private m_bTrackUser32 As Boolean
Private m_bInCtrl As Boolean
Private m_snxL As Single
Private m_snyL As Single
Private m_hListView As Long
Private m_hHeader As Long
Private m_hILSmall As Long
Private m_hILLarge As Long
Private m_hILHeader As Long
Private m_hFont As Long
Private m_uIPAO As IPAOHookStruct
Private WithEvents m_oFont As StdFont
Attribute m_oFont.VB_VarHelpID = -1
'-- Event declarations:
Public Event Click()
Public Event DblClick()
Public Event ItemClick(Item As Integer)
Public Event ItemCheck(Item As Integer)
Public Event ColumnClick(Column As Integer)
Public Event ColumnRightClick(Column As Integer)
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public Event KeyPress(KeyAscii As Integer)
Public Event KeyUp(KeyCode As Integer, Shift As Integer)
Public Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Public Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Public Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Public Event MouseEnter()
Public Event MouseLeave()
Public Event BeforeLabelEdit(Cancel As Integer)
Public Event AfterLabelEdit(Cancel As Integer, NewString As String)
Public Event Resize()
'//
Public Event OnSubItemPrePaint(ByVal Item As Integer, ByVal SubItem As Integer, TextBackColor As Long, TextForeColor As Long, Process As Boolean)
'//
'========================================================================================
' Subclasser declarations
'========================================================================================
Private Enum eMsgWhen
[MSG_AFTER] = 1 'Message calls back after the original (previous) WndProc
[MSG_BEFORE] = 2 'Message calls back before the original (previous) WndProc
[MSG_BEFORE_AND_AFTER] = [MSG_AFTER] Or [MSG_BEFORE] 'Message calls back before and after the original (previous) WndProc
End Enum
Private Const ALL_MESSAGES As Long = -1 'All messages added or deleted
Private Const GMEM_FIXED As Long = &H0
Private Const GWL_WNDPROC As Long = -4 'Get/SetWindow offset to the WndProc procedure address
Private Const PATCH_04 As Long = 88 'Table B (before) address patch offset
Private Const PATCH_05 As Long = 93 'Table B (before) entry count patch offset
Private Const PATCH_08 As Long = 132 'Table A (after) address patch offset
Private Const PATCH_09 As Long = 137 'Table A (after) entry count patch offset
Private Type tSubData 'Subclass data type
hWnd As Long 'Handle of the window being subclassed
nAddrSub As Long 'The address of our new WndProc (aCode)
nAddrOrig As Long 'The address of the pre-existing WndProc
nMsgCntA As Long 'Msg after table entry count
nMsgCntB As Long 'Msg before table entry count
aMsgTblA() As Long 'Msg after table array
aMsgTblB() As Long 'Msg Before table array
End Type
Private sc_aSubData() As tSubData 'Subclass data array
Private Declare Sub RtlMoveMemory Lib "kernel32" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -