(* OCaml-Win32
 * win32_treeview.ml
 * Copyright (c) 2002-2004 by Harry Chomsky
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *)

open Win32_core

(********************************************************************)
(* User Interface: Windows User Experience: Windows Shell: SDK: Windows Controls: Individual Control Information: Tree-View Controls *)

let wc_treeview = "SysTreeView32"

type htreeitem

external eq_htreeitem : htreeitem -> htreeitem -> bool = "eq_htreeitem"
external is_null_htreeitem : item:htreeitem -> bool = "is_null_htreeitem"
external get_null_htreeitem : unit -> htreeitem = "get_null_htreeitem"
let null_htreeitem = get_null_htreeitem ()
external get_root_htreeitem : unit -> htreeitem = "get_root_htreeitem"
let root_htreeitem = get_root_htreeitem ()
external int32_of_htreeitem : htreeitem -> int32 = "int32_of_htreeitem"
external htreeitem_of_int32 : int32 -> htreeitem = "htreeitem_of_int32"

type tvitem_state = {
    tvis_bold : bool option;
    tvis_cut : bool option;
    tvis_drophilited : bool option;
    tvis_expanded : bool option;
    tvis_expandedonce : bool option;
    tvis_expandpartial : bool option;
    tvis_selected : bool option;
    tvis_overlay : int option;
    tvis_state_image : int option }
let default_tvitem_state = {
    tvis_bold = None;
    tvis_cut = None;
    tvis_drophilited = None;
    tvis_expanded = None;
    tvis_expandedonce = None;
    tvis_expandpartial = None;
    tvis_selected = None;
    tvis_overlay = None;
    tvis_state_image = None }

type tvitem_children =
    Tvic_no
  | Tvic_yes
  | Tvic_callback

type tvitem = {
    tvi_item : htreeitem option;
    tvi_state : tvitem_state option;
    tvi_text : common_control_text option;
    tvi_image : common_control_image_index option;
    tvi_selected_image : common_control_image_index option;
    tvi_children : tvitem_children option;
    tvi_lparam : int32 option;
    tvi_integral : int option }
let default_tvitem = {
    tvi_item = None;
    tvi_state = None;
    tvi_text = None;
    tvi_image = None;
    tvi_selected_image = None;
    tvi_children = None;
    tvi_lparam = None;
    tvi_integral = None }

type tvitem_state_component =
    Tvis_bold
  | Tvis_cut
  | Tvis_drophilited
  | Tvis_expanded
  | Tvis_expandedonce
  | Tvis_expandpartial
  | Tvis_selected
  | Tvis_overlay
  | Tvis_state_image
let all_tvitem_state_components = [
    Tvis_bold;
    Tvis_cut;
    Tvis_drophilited;
    Tvis_expanded;
    Tvis_expandedonce;
    Tvis_expandpartial;
    Tvis_selected;
    Tvis_overlay;
    Tvis_state_image ]

type tvitem_component =
    Tvif_state of tvitem_state_component list
  | Tvif_text of int
  | Tvif_image
  | Tvif_selectedimage
  | Tvif_children
  | Tvif_param
  | Tvif_integral
let all_tvitem_components = [
    Tvif_state all_tvitem_state_components;
    Tvif_text 256;
    Tvif_image;
    Tvif_selectedimage;
    Tvif_children;
    Tvif_param;
    Tvif_integral ]

type treeview_which_image_list =
    TVSIL_NORMAL
  | TVSIL_STATE

type treeview_expand_action =
    TVE_COLLAPSE
  | TVE_EXPAND
  | TVE_TOGGLE

type treeview_expand_option =
    TVE_COLLAPSERESET
  | TVE_EXPANDPARTIAL

external treeview_delete_all_items : wnd:hwnd -> unit = "treeview_delete_all_items"

external treeview_get_child : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_child"

external treeview_get_drop_hilight : wnd:hwnd -> htreeitem = "treeview_get_drop_hilight"

external treeview_get_first_visible : wnd:hwnd -> htreeitem = "treeview_get_first_visible"

external treeview_get_last_visible : wnd:hwnd -> htreeitem = "treeview_get_last_visible"

external treeview_get_next_sibling : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_next_sibling"

external treeview_get_next_visible : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_next_visible"

external treeview_get_parent : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_parent"

external treeview_get_prev_sibling : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_prev_sibling"

external treeview_get_prev_visible : wnd:hwnd -> item:htreeitem -> htreeitem = "treeview_get_prev_visible"

external treeview_get_root : wnd:hwnd -> htreeitem = "treeview_get_root"

external treeview_get_selection : wnd:hwnd -> htreeitem = "treeview_get_selection"

external treeview_select_drop_target : wnd:hwnd -> item:htreeitem -> unit = "treeview_select_drop_target"

external treeview_select_item : wnd:hwnd -> item:htreeitem -> unit = "treeview_select_item"

external treeview_select_set_first_visible : wnd:hwnd -> item:htreeitem -> unit = "treeview_select_set_first_visible"

(* Styles *)

type treeview_style_option =
    TVS_CHECKBOXES
  | TVS_DISABLEDRAGDROP
  | TVS_EDITLABELS
  | TVS_FULLROWSELECT
  | TVS_HASBUTTONS
  | TVS_HASLINES
  | TVS_INFOTIP
  | TVS_LINESATROOT
  | TVS_NONEVENHEIGHT
  | TVS_NOSCROLL
  | TVS_NOTOOLTIPS
  | TVS_RTLREADING
  | TVS_SHOWSELALWAYS
  | TVS_SINGLEEXPAND
  | TVS_TRACKSELECT

external treeview_style_of_option : treeview_style_option -> style = "treeview_style_of_option"

let treeview_style_of_options = special_style_of_options ~special_func:treeview_style_of_option

(* Messages *)

let tv_first = 0x1100

let tvm_createdragimage = tv_first + 18
external pack_tvm_createdragimage : item:htreeitem -> message_contents = "pack_tvm_createdragimage"
external unpack_tvm_createdragimage : message_result -> himagelist = "unpack_tvm_createdragimage"
let issue_tvm_createdragimage ~sender ~item = unpack_tvm_createdragimage (sender ~msg:(pack_tvm_createdragimage ~item))

let tvm_deleteitem = tv_first + 1
external pack_tvm_deleteitem : item:htreeitem -> message_contents = "pack_tvm_deleteitem"
external unpack_tvm_deleteitem : message_result -> unit = "unpack_tvm_deleteitem"
let issue_tvm_deleteitem ~sender ~item = unpack_tvm_deleteitem (sender ~msg:(pack_tvm_deleteitem ~item))

let tvm_editlabel = tv_first + 14
external pack_tvm_editlabel : item:htreeitem -> message_contents = "pack_tvm_editlabel"
external unpack_tvm_editlabel : message_result -> hwnd = "unpack_tvm_editlabel"
let issue_tvm_editlabel ~sender ~item = unpack_tvm_editlabel (sender ~msg:(pack_tvm_editlabel ~item))

let tvm_endeditlabelnow = tv_first + 22
external pack_tvm_endeditlabelnow : cancel:bool -> message_contents = "pack_tvm_endeditlabelnow"
external unpack_tvm_endeditlabelnow : message_result -> unit = "unpack_tvm_endeditlabelnow"
let issue_tvm_endeditlabelnow ~sender ~cancel = unpack_tvm_endeditlabelnow (sender ~msg:(pack_tvm_endeditlabelnow ~cancel))

let tvm_ensurevisible = tv_first + 20
external pack_tvm_ensurevisible : item:htreeitem -> message_contents = "pack_tvm_ensurevisible"
external unpack_tvm_ensurevisible : message_result -> bool = "unpack_tvm_ensurevisible"
let issue_tvm_ensurevisible ~sender ~item = unpack_tvm_ensurevisible (sender ~msg:(pack_tvm_ensurevisible ~item))

let tvm_expand = tv_first + 2
external pack_tvm_expand :
    action:treeview_expand_action ->
    options:treeview_expand_option list ->
    item:htreeitem ->
    message_contents = "pack_tvm_expand"
external unpack_tvm_expand : message_result -> bool = "unpack_tvm_expand"
let issue_tvm_expand ~sender ~action ~options ~item = unpack_tvm_expand (sender ~msg:(pack_tvm_expand ~action ~options ~item))

let tvm_getbkcolor = tv_first + 31
let pack_tvm_getbkcolor = pack_simple_message ~id:tvm_getbkcolor
external unpack_tvm_getbkcolor : message_result -> color = "unpack_tvm_getbkcolor"
let issue_tvm_getbkcolor ~sender = unpack_tvm_getbkcolor (sender ~msg:pack_tvm_getbkcolor)

let tvm_getcount = tv_first + 5
let pack_tvm_getcount = pack_simple_message ~id:tvm_getcount
external unpack_tvm_getcount : message_result -> int = "unpack_tvm_getcount"
let issue_tvm_getcount ~sender = unpack_tvm_getcount (sender ~msg:pack_tvm_getcount)

let tvm_geteditcontrol = tv_first + 15
let pack_tvm_geteditcontrol = pack_simple_message ~id:tvm_geteditcontrol
external unpack_tvm_geteditcontrol : message_result -> hwnd = "unpack_tvm_geteditcontrol"
let issue_tvm_geteditcontrol ~sender = unpack_tvm_geteditcontrol (sender ~msg:pack_tvm_geteditcontrol)

let tvm_getimagelist = tv_first + 8
external pack_tvm_getimagelist : which:treeview_which_image_list -> message_contents = "pack_tvm_getimagelist"
external unpack_tvm_getimagelist : message_result -> himagelist = "unpack_tvm_getimagelist"
let issue_tvm_getimagelist ~sender ~which = unpack_tvm_getimagelist (sender ~msg:(pack_tvm_getimagelist ~which))

let tvm_getindent = tv_first + 6
let pack_tvm_getindent = pack_simple_message ~id:tvm_getindent
external unpack_tvm_getindent : message_result -> int = "unpack_tvm_getindent"
let issue_tvm_getindent ~sender = unpack_tvm_getindent (sender ~msg:pack_tvm_getindent)

let tvm_getinsertmarkcolor = tv_first + 38
let pack_tvm_getinsertmarkcolor = pack_simple_message ~id:tvm_getinsertmarkcolor
external unpack_tvm_getinsertmarkcolor : message_result -> color = "unpack_tvm_getinsertmarkcolor"
let issue_tvm_getinsertmarkcolor ~sender = unpack_tvm_getinsertmarkcolor (sender ~msg:pack_tvm_getinsertmarkcolor)

let tvm_getisearchstring = tv_first + 23
external issue_tvm_getisearchstring : sender:message_sender -> string = "issue_tvm_getisearchstring"

let tvm_getitem = tv_first + 12
external issue_tvm_getitem :
    sender:message_sender ->
    item:htreeitem ->
    mask:tvitem_component list ->
    tvitem = "issue_tvm_getitem"

let tvm_getitemheight = tv_first + 28
let pack_tvm_getitemheight = pack_simple_message ~id:tvm_getitemheight
external unpack_tvm_getitemheight : message_result -> int = "unpack_tvm_getitemheight"
let issue_tvm_getitemheight ~sender = unpack_tvm_getitemheight (sender ~msg:pack_tvm_getitemheight)

let tvm_getitemrect = tv_first + 4
external issue_tvm_getitemrect :
    sender:message_sender ->
    item:htreeitem ->
    text_only:bool ->
    rect option = "issue_tvm_getitemrect"

let tvm_getnextitem = tv_first + 10
type treeview_next_item_direction =
    TVGN_CARET
  | TVGN_CHILD
  | TVGN_DROPHILITE
  | TVGN_FIRSTVISIBLE
  | TVGN_LASTVISIBLE
  | TVGN_NEXT
  | TVGN_NEXTVISIBLE
  | TVGN_PARENT
  | TVGN_PREVIOUS
  | TVGN_PREVIOUSVISIBLE
  | TVGN_ROOT
external pack_tvm_getnextitem :
    item:htreeitem ->
    direction:treeview_next_item_direction ->
    message_contents = "pack_tvm_getnextitem"
external unpack_tvm_getnextitem : message_result -> htreeitem = "unpack_tvm_getnextitem"
let issue_tvm_getnextitem ~sender ~item ~direction = unpack_tvm_getnextitem (sender ~msg:(pack_tvm_getnextitem ~item ~direction))

let tvm_getscrolltime = tv_first + 34
let pack_tvm_getscrolltime = pack_simple_message ~id:tvm_getscrolltime
external unpack_tvm_getscrolltime : message_result -> int = "unpack_tvm_getscrolltime"
let issue_tvm_getscrolltime ~sender = unpack_tvm_getscrolltime (sender ~msg:pack_tvm_getscrolltime)

let tvm_gettextcolor = tv_first + 32
let pack_tvm_gettextcolor = pack_simple_message ~id:tvm_gettextcolor
external unpack_tvm_gettextcolor : message_result -> color = "unpack_tvm_gettextcolor"
let issue_tvm_gettextcolor ~sender = unpack_tvm_gettextcolor (sender ~msg:pack_tvm_gettextcolor)

let tvm_gettooltips = tv_first + 25
let pack_tvm_gettooltips = pack_simple_message ~id:tvm_gettooltips
external unpack_tvm_gettooltips : message_result -> hwnd = "unpack_tvm_gettooltips"
let issue_tvm_gettooltips ~sender = unpack_tvm_gettooltips (sender ~msg:pack_tvm_gettooltips)

(* tvm_getunicodeformat: use ccm_getunicodeformat *)

let tvm_getvisiblecount = tv_first + 16
let pack_tvm_getvisiblecount = pack_simple_message ~id:tvm_getvisiblecount
external unpack_tvm_getvisiblecount : message_result -> int = "unpack_tvm_getvisiblecount"
let issue_tvm_getvisiblecount ~sender = unpack_tvm_getvisiblecount (sender ~msg:pack_tvm_getvisiblecount)

let tvm_hittest = tv_first + 17
type treeview_hit_test_direction =
    TVHT_ABOVE
  | TVHT_BELOW
  | TVHT_TOLEFT
  | TVHT_TORIGHT
type treeview_hit_test_part =
    TVHT_ONITEMBUTTON
  | TVHT_ONITEMICON
  | TVHT_ONITEMINDENT
  | TVHT_ONITEMLABEL
  | TVHT_ONITEMRIGHT
  | TVHT_ONITEMSTATEICON
type treeview_hit_test_result =
    Tvhtr_outside of treeview_hit_test_direction list
  | Tvhtr_nowhere
  | Tvhtr_onitem of htreeitem * treeview_hit_test_part
external issue_tvm_hittest : sender:message_sender -> pt:point -> treeview_hit_test_result = "issue_tvm_hittest"

let tvm_insertitem = tv_first + 0
type treeview_insert_location =
    Tvil_first
  | Tvil_last
  | Tvil_sort
  | Tvil_after of htreeitem
external issue_tvm_insertitem :
    sender:message_sender ->
    parent:htreeitem ->
    location:treeview_insert_location ->
    tvitem:tvitem ->
    htreeitem = "issue_tvm_insertitem"

let tvm_selectitem = tv_first + 11
type treeview_select_action =
    Tvsa_select
  | Tvsa_drop_hilite
  | Tvsa_set_first_visible
external pack_tvm_selectitem : item:htreeitem -> action:treeview_select_action -> message_contents = "pack_tvm_selectitem"
external unpack_tvm_selectitem : message_result -> unit = "unpack_tvm_selectitem"
let issue_tvm_selectitem ~sender ~item ~action = unpack_tvm_selectitem (sender ~msg:(pack_tvm_selectitem ~item ~action))

let tvm_setbkcolor = tv_first + 29
external pack_tvm_setbkcolor : color:color -> message_contents = "pack_tvm_setbkcolor"
external unpack_tvm_setbkcolor : message_result -> color = "unpack_tvm_setbkcolor"
let issue_tvm_setbkcolor ~sender ~color = unpack_tvm_setbkcolor (sender ~msg:(pack_tvm_setbkcolor ~color))

let tvm_setimagelist = tv_first + 9
external pack_tvm_setimagelist : which:treeview_which_image_list -> iml:himagelist -> message_contents = "pack_tvm_setimagelist"
external unpack_tvm_setimagelist : message_result -> himagelist = "unpack_tvm_setimagelist"
let issue_tvm_setimagelist ~sender ~which ~iml = unpack_tvm_setimagelist (sender ~msg:(pack_tvm_setimagelist ~which ~iml))

let tvm_setindent = tv_first + 7
external pack_tvm_setindent : indent:int -> message_contents = "pack_tvm_setindent"
let unpack_tvm_setindent = ignore
let issue_tvm_setindent ~sender ~indent = unpack_tvm_setindent (sender ~msg:(pack_tvm_setindent ~indent))

let tvm_setinsertmark = tv_first + 26
external pack_tvm_setinsertmark : item:htreeitem -> after:bool -> message_contents = "pack_tvm_setinsertmark"
external unpack_tvm_setinsertmark : message_result -> unit = "unpack_tvm_setinsertmark"
let issue_tvm_setinsertmark ~sender ~item ~after = unpack_tvm_setinsertmark (sender ~msg:(pack_tvm_setinsertmark ~item ~after))

let tvm_setinsertmarkcolor = tv_first + 37
external pack_tvm_setinsertmarkcolor : color:color -> message_contents = "pack_tvm_setinsertmarkcolor"
external unpack_tvm_setinsertmarkcolor : message_result -> color = "unpack_tvm_setinsertmarkcolor"
let issue_tvm_setinsertmarkcolor ~sender ~color = unpack_tvm_setinsertmarkcolor (sender ~msg:(pack_tvm_setinsertmarkcolor ~color))

let tvm_setitem = tv_first + 13
external issue_tvm_setitem : sender:message_sender -> tvitem:tvitem -> unit = "issue_tvm_setitem"

let tvm_setitemheight = tv_first + 27
external pack_tvm_setitemheight : height:int -> message_contents = "pack_tvm_setitemheight"
external unpack_tvm_setitemheight : message_result -> int = "unpack_tvm_setitemheight"
let issue_tvm_setitemheight ~sender ~height = unpack_tvm_setitemheight (sender ~msg:(pack_tvm_setitemheight ~height))

let tvm_setscrolltime = tv_first + 33
external pack_tvm_setscrolltime : time:int -> message_contents = "pack_tvm_setscrolltime"
external unpack_tvm_setscrolltime : message_result -> int = "unpack_tvm_setscrolltime"
let issue_tvm_setscrolltime ~sender ~time = unpack_tvm_setscrolltime (sender ~msg:(pack_tvm_setscrolltime ~time))

let tvm_settextcolor = tv_first + 30
external pack_tvm_settextcolor : color:color -> message_contents = "pack_tvm_settextcolor"
external unpack_tvm_settextcolor : message_result -> color = "unpack_tvm_settextcolor"
let issue_tvm_settextcolor ~sender ~color = unpack_tvm_settextcolor (sender ~msg:(pack_tvm_settextcolor ~color))

let tvm_settooltips = tv_first + 24
external pack_tvm_settooltips : tooltips:hwnd -> message_contents = "pack_tvm_settooltips"
external unpack_tvm_settooltips : message_result -> hwnd = "unpack_tvm_settooltips"
let issue_tvm_settooltips ~sender ~tooltips = unpack_tvm_settooltips (sender ~msg:(pack_tvm_settooltips ~tooltips))

(* tvm_setunicodeformat: use ccm_setunicodeformat *)

let tvm_sortchildren = tv_first + 19
external pack_tvm_sortchildren : item:htreeitem -> message_contents = "pack_tvm_sortchildren"
external unpack_tvm_sortchildren : message_result -> unit = "unpack_tvm_sortchildren"
let issue_tvm_sortchildren ~sender ~item = unpack_tvm_sortchildren (sender ~msg:(pack_tvm_sortchildren ~item))

let tvm_sortchildrencb = tv_first + 21
external issue_tvm_sortchildrencb :
    sender:message_sender ->
    item:htreeitem ->
    compare:(int32 -> int32 -> int) ->
    unit = "issue_tvm_sortchildrencb"

(* Notifications *)

type nmtvcustomdraw = {
    nmtvcd_item_spec : htreeitem;
    nmtvcd_text_color : color;
    nmtvcd_text_bk_color : color;
    nmtvcd_level : int }
external unpack_nmtvcustomdraw : msg:message_contents -> nmtvcustomdraw = "unpack_nmtvcustomdraw"

type nmtreeview_delete = {
    nmtvd_item : tvitem }
external unpack_nmtreeview_delete : msg:message_contents -> nmtreeview_delete = "unpack_nmtreeview_delete"

type nmtreeview_drag = {
    nmtvdr_item : tvitem;
    nmtvdr_pt : point }
external unpack_nmtreeview_drag : msg:message_contents -> nmtreeview_drag = "unpack_nmtreeview_drag"

type nmtreeview_expand = {
    nmtve_item : tvitem;
    nmtve_action : treeview_expand_action }
external unpack_nmtreeview_expand : msg:message_contents -> nmtreeview_expand = "unpack_nmtreeview_expand"

type nmtreeview_selchange_action =
    TVC_BYKEYBOARD
  | TVC_BYMOUSE
  | TVC_UNKNOWN
type nmtreeview_selchange = {
    nmtvsc_item_old : tvitem;
    nmtvsc_item_new : tvitem;
    nmtvsc_action : nmtreeview_selchange_action }
external unpack_nmtreeview_selchange : msg:message_contents -> nmtreeview_selchange = "unpack_nmtreeview_selchange"

type nmtreeview_singleexpand = {
    nmtvse_item : tvitem }
external unpack_nmtreeview_singleexpand : msg:message_contents -> nmtreeview_singleexpand = "unpack_nmtreeview_singleexpand"

type nmtvdispinfo = {
    nmtvdi_item : tvitem }
external unpack_nmtvdispinfo : msg:message_contents -> nmtvdispinfo = "unpack_nmtvdispinfo"

type nmtvkeydown = {
    nmtvkd_key : virtual_key_code }
external unpack_nmtvkeydown : msg:message_contents -> nmtvkeydown = "unpack_nmtvkeydown"

let tvn_first = -400
let tvn_last = -499

let tvn_begindrag = tvn_first - 7
let on_tvn_begindrag = on_notify_message ~code:tvn_begindrag ~unpack:unpack_nmtreeview_drag ~return:return_simple_message

let tvn_beginlabeledit = tvn_first - 10
let on_tvn_beginlabeledit = on_notify_message ~code:tvn_beginlabeledit ~unpack:unpack_nmtvdispinfo ~return:return_common_notify

let tvn_beginrdrag = tvn_first - 8
let on_tvn_beginrdrag = on_notify_message ~code:tvn_beginrdrag ~unpack:unpack_nmtreeview_drag ~return:return_simple_message

let tvn_deleteitem = tvn_first - 9
let on_tvn_deleteitem = on_notify_message ~code:tvn_deleteitem ~unpack:unpack_nmtreeview_delete ~return:return_simple_message

let tvn_endlabeledit = tvn_first - 11
let on_tvn_endlabeledit = on_notify_message ~code:tvn_endlabeledit ~unpack:unpack_nmtvdispinfo ~return:return_common_notify

let tvn_getdispinfo = tvn_first - 3
type tvn_getdispinfo_handler =
    wnd:hwnd ->
    msg:message_contents ->
    id:int ->
    hdr:nmhdr ->
    item:htreeitem ->
    state:tvitem_state ->
    lparam:int32 ->
    mask:tvitem_component list ->
    (tvitem * bool) message_handler_result
external on_tvn_getdispinfo :
    tvn_getdispinfo_handler ->
    wnd:hwnd ->
    msg:message_contents ->
    message_result option = "on_tvn_getdispinfo"

let tvn_getinfotip = tvn_first - 13
type tvn_getinfotip_handler =
    wnd:hwnd ->
    msg:message_contents ->
    id:int ->
    hdr:nmhdr ->
    item:htreeitem ->
    lparam:int32 ->
    text:string ->
    max_length:int ->
    string option message_handler_result
external on_tvn_getinfotip :
    tvn_getinfotip_handler ->
    wnd:hwnd ->
    msg:message_contents ->
    message_result option = "on_tvn_getinfotip"

let tvn_itemexpanded = tvn_first - 6
let on_tvn_itemexpanded = on_notify_message ~code:tvn_itemexpanded ~unpack:unpack_nmtreeview_expand ~return:return_simple_message

let tvn_itemexpanding = tvn_first - 5
let on_tvn_itemexpanding = on_notify_message ~code:tvn_itemexpanding ~unpack:unpack_nmtreeview_expand ~return:return_common_notify

let tvn_keydown = tvn_first - 12
let on_tvn_keydown = on_notify_message ~code:tvn_keydown ~unpack:unpack_nmtvkeydown ~return:return_common_notify

let tvn_selchanged = tvn_first - 2
let on_tvn_selchanged = on_notify_message ~code:tvn_selchanged ~unpack:unpack_nmtreeview_selchange ~return:return_simple_message

let tvn_selchanging = tvn_first - 1
let on_tvn_selchanging = on_notify_message ~code:tvn_selchanging ~unpack:unpack_nmtreeview_selchange ~return:return_common_notify

let tvn_setdispinfo = tvn_first - 4
let on_tvn_setdispinfo = on_notify_message ~code:tvn_setdispinfo ~unpack:unpack_nmtvdispinfo ~return:return_simple_message

let tvn_singleexpand = tvn_first - 15
let on_tvn_singleexpand = on_notify_message ~code:tvn_singleexpand ~unpack:unpack_nmtreeview_singleexpand ~return:return_simple_message
