MCPcopy Create free account
hub / github.com/lxn/walk / WndProc

Method WndProc

treeview.go:559–642  ·  view source on GitHub ↗
(hwnd win.HWND, msg uint32, wParam, lParam uintptr)

Source from the content-addressed store, hash-verified

557}
558
559func (tv *TreeView) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr {
560 switch msg {
561 case win.WM_GETDLGCODE:
562 if wParam == win.VK_RETURN {
563 return win.DLGC_WANTALLKEYS
564 }
565
566 case win.WM_NOTIFY:
567 nmhdr := (*win.NMHDR)(unsafe.Pointer(lParam))
568
569 switch nmhdr.Code {
570 case win.TVN_GETDISPINFO:
571 nmtvdi := (*win.NMTVDISPINFO)(unsafe.Pointer(lParam))
572 item := tv.handle2Item[nmtvdi.Item.HItem]
573
574 if nmtvdi.Item.Mask&win.TVIF_TEXT != 0 {
575 text := item.Text()
576 utf16 := syscall.StringToUTF16(text)
577 buf := (*[264]uint16)(unsafe.Pointer(nmtvdi.Item.PszText))
578 max := mini(len(utf16), int(nmtvdi.Item.CchTextMax))
579 copy((*buf)[:], utf16[:max])
580 (*buf)[max-1] = 0
581 }
582 if nmtvdi.Item.Mask&win.TVIF_CHILDREN != 0 {
583 if hc, ok := item.(HasChilder); ok {
584 if hc.HasChild() {
585 nmtvdi.Item.CChildren = 1
586 } else {
587 nmtvdi.Item.CChildren = 0
588 }
589 } else {
590 nmtvdi.Item.CChildren = int32(item.ChildCount())
591 }
592 }
593
594 case win.TVN_ITEMEXPANDING:
595 nmtv := (*win.NMTREEVIEW)(unsafe.Pointer(lParam))
596 item := tv.handle2Item[nmtv.ItemNew.HItem]
597
598 if nmtv.Action == win.TVE_EXPAND && tv.lazyPopulation {
599 info := tv.item2Info[item]
600 if len(info.child2Handle) == 0 {
601 tv.insertChildren(item)
602 }
603 }
604
605 case win.TVN_ITEMEXPANDED:
606 nmtv := (*win.NMTREEVIEW)(unsafe.Pointer(lParam))
607 item := tv.handle2Item[nmtv.ItemNew.HItem]
608
609 switch nmtv.Action {
610 case win.TVE_COLLAPSE:
611 tv.expandedChangedPublisher.Publish(item)
612
613 case win.TVE_COLLAPSERESET:
614
615 case win.TVE_EXPAND:
616 tv.expandedChangedPublisher.Publish(item)

Callers

nothing calls this directly

Calls 7

insertChildrenMethod · 0.95
miniFunction · 0.85
HasChildMethod · 0.80
TextMethod · 0.65
ChildCountMethod · 0.65
WndProcMethod · 0.65
PublishMethod · 0.45

Tested by

no test coverage detected