functions as yet, but I already thought about.
Code: Select all
; ==================================================================================================================================
LVH_Add(HLV, Options := "", Item := "", Subitems*) {
Static GETITEMCOUNT := 0x1004
Row := DllCall("SendMessage", "Ptr", HLV, "UInt", GETITEMCOUNT, "Ptr", 0, "Ptr", 0, "Int") + 1
Return LVH_Insert(HLV, Row, Options, Item, Subitems*)
}
; ==================================================================================================================================
LVH_Insert(HLV, RowNumber, Options := "", Item := "", Subitems*) {
Static INSERTITEM := A_IsUnicode ? 0x104D : 0x1007
, SETITEMSTATE := 0x102B
, SETITEMTEXT := A_IsUnicode ? 0x1074 : 0x102E
, OffText := 16 + A_PtrSize
, OffImage := OffText + A_PtrSize + 4
If Rownumber Is Not Integer
Return 0
If (RowNumber < 1)
Return 0
Icon := States := 0
If (Options <> "")
Options := " " . RegExReplace(Options, "\s+", " ") . " "
, Icon := RegExMatch(Options, "i) Icon\K\d+", N) ? N - 1 : 0
, States := (InStr(Options, " Check ") ? 0x2000 : 0)
| (InStr(Options, " Focus ") ? 0x0001 : 0)
| (InStr(Options, " Select ") ? 0x0002 : 0)
, StMask := States | (States & 0x2000 ? 0x1000 : 0)
VarSetCapacity(LVITEM, 40 + (A_PtrSize * 5), 0) ; LVITEM structure
, NumPut(0x03, LVITEM, "UInt") ; mask
, NumPut(RowNumber - 1, LVITEM, 4, "Int") ; iItem
, NumPut(0, LVITEM, 8, "Int") ; iSubItem
, NumPut(&Item, LVITEM, OffText, "Ptr") ; pszText
, NumPut(Icon, LVITEM, OffImage, "Int") ; iImage
, Row := DllCall("SendMessage", "Ptr", HLV, "UInt", INSERTITEM, "Ptr", 0, "Ptr", &LVITEM, "Int")
If (Row > -1) {
For Index, Text In Subitems
NumPut(Row, LVITEM, 4, "Int")
, NumPut(A_Index, LVITEM, 8, "Int")
, NumPut(&Text, LVITEM, OffText, "Ptr")
, DllCall("SendMessage", "Ptr", HLV, "UInt", SETITEMTEXT, "Ptr", Row, "Ptr", &LVITEM)
If (States)
NumPut(States, LVITEM, 12, "UInt") ; state
, NumPut(StMask, LVITEM, 16, "UInt") ; stateMask
, DllCall("SendMessage", "Ptr", HLV, "UInt", SETITEMSTATE, "Ptr", Row, "Ptr", &LVITEM)
}
Return (Row + 1)
}
; ==================================================================================================================================
are supported.