MCPcopy Index your code
hub / github.com/lxn/walk / setSortIcon

Method setSortIcon

tableview.go:1069–1115  ·  view source on GitHub ↗

*func (tv *TableView) selectedColumnIndex() int { return tv.fromLVColIdx(tv.SendMessage(LVM_GETSELECTEDCOLUMN, 0, 0)) }*/ func (tv *TableView) setSelectedColumnIndex(index int) { tv.SendMessage(win.LVM_SETSELECTEDCOLUMN, uintptr(tv.toLVColIdx(index)), 0) }

(index int, order SortOrder)

Source from the content-addressed store, hash-verified

1067// }
1068
1069func (tv *TableView) setSortIcon(index int, order SortOrder) error {
1070 idx := int(tv.toLVColIdx(index))
1071
1072 frozenCount := tv.visibleFrozenColumnCount()
1073
1074 for i, col := range tv.visibleColumns() {
1075 item := win.HDITEM{
1076 Mask: win.HDI_FORMAT,
1077 }
1078
1079 var headerHwnd win.HWND
1080 var offset int
1081 if col.frozen {
1082 headerHwnd = tv.hwndFrozenHdr
1083 } else {
1084 headerHwnd = tv.hwndNormalHdr
1085 offset = -frozenCount
1086 }
1087
1088 iPtr := uintptr(offset + i)
1089 itemPtr := uintptr(unsafe.Pointer(&item))
1090
1091 if win.SendMessage(headerHwnd, win.HDM_GETITEM, iPtr, itemPtr) == 0 {
1092 return newError("SendMessage(HDM_GETITEM)")
1093 }
1094
1095 if i == idx {
1096 switch order {
1097 case SortAscending:
1098 item.Fmt &^= win.HDF_SORTDOWN
1099 item.Fmt |= win.HDF_SORTUP
1100
1101 case SortDescending:
1102 item.Fmt &^= win.HDF_SORTUP
1103 item.Fmt |= win.HDF_SORTDOWN
1104 }
1105 } else {
1106 item.Fmt &^= win.HDF_SORTDOWN | win.HDF_SORTUP
1107 }
1108
1109 if win.SendMessage(headerHwnd, win.HDM_SETITEM, iPtr, itemPtr) == 0 {
1110 return newError("SendMessage(HDM_SETITEM)")
1111 }
1112 }
1113
1114 return nil
1115}
1116
1117// ColumnClicked returns the event that is published after a column header was
1118// clicked.

Callers 1

attachModelMethod · 0.95

Calls 5

toLVColIdxMethod · 0.95
visibleColumnsMethod · 0.95
newErrorFunction · 0.85
SendMessageMethod · 0.65

Tested by

no test coverage detected