MCPcopy
hub / github.com/lxn/walk / insertItemAfter

Method insertItemAfter

treeview.go:369–407  ·  view source on GitHub ↗
(item TreeItem, hInsertAfter win.HTREEITEM)

Source from the content-addressed store, hash-verified

367}
368
369func (tv *TreeView) insertItemAfter(item TreeItem, hInsertAfter win.HTREEITEM) (win.HTREEITEM, error) {
370 var tvins win.TVINSERTSTRUCT
371 tvi := &tvins.Item
372
373 tvi.Mask = win.TVIF_CHILDREN | win.TVIF_TEXT
374 tvi.PszText = win.LPSTR_TEXTCALLBACK
375 tvi.CChildren = win.I_CHILDRENCALLBACK
376
377 tv.setTVITEMImageInfo(tvi, item)
378
379 parent := item.Parent()
380
381 if parent == nil {
382 tvins.HParent = win.TVI_ROOT
383 } else {
384 info := tv.item2Info[parent]
385 if info == nil {
386 return 0, newError("invalid parent")
387 }
388 tvins.HParent = info.handle
389 }
390
391 tvins.HInsertAfter = hInsertAfter
392
393 hItem := win.HTREEITEM(tv.SendMessage(win.TVM_INSERTITEM, 0, uintptr(unsafe.Pointer(&tvins))))
394 if hItem == 0 {
395 return 0, newError("TVM_INSERTITEM failed")
396 }
397 tv.item2Info[item] = &treeViewItemInfo{hItem, make(map[TreeItem]win.HTREEITEM)}
398 tv.handle2Item[hItem] = item
399
400 if !tv.lazyPopulation {
401 if err := tv.insertChildren(item); err != nil {
402 return 0, err
403 }
404 }
405
406 return hItem, nil
407}
408
409func (tv *TreeView) insertChildren(parent TreeItem) error {
410 info := tv.item2Info[parent]

Callers 2

SetModelMethod · 0.95
insertItemMethod · 0.95

Calls 5

setTVITEMImageInfoMethod · 0.95
insertChildrenMethod · 0.95
newErrorFunction · 0.85
ParentMethod · 0.65
SendMessageMethod · 0.65

Tested by

no test coverage detected