pub fn insert_item<'a>(&self, new: &'a str, parent: Option<&TreeItem>, position: TreeInsert) -> TreeItem {
        use winapi::um::commctrl::{TVM_INSERTITEMW, TVINSERTSTRUCTW, TVI_FIRST, TVI_LAST, TVI_ROOT, TVI_SORT, TVIF_TEXT};
        use winapi::um::commctrl::TVINSERTSTRUCTW_u;
        use winapi::um::winnt::LPWSTR;

        let handle = check_hwnd(&self.handle, NOT_BOUND, BAD_HANDLE);

        let insert = match position {
            TreeInsert::First => TVI_FIRST,
            TreeInsert::Last => TVI_LAST,
            TreeInsert::Root => TVI_ROOT,
            TreeInsert::Sort => TVI_SORT,
            TreeInsert::After(i) => i
        };

        let text = to_utf16(new);

        let item = {
            let mut item: TVINSERTSTRUCTW_u = unsafe { mem::zeroed() };
            let i = unsafe { item.item_mut() };
            i.mask = TVIF_TEXT;
            i.pszText = text.as_ptr() as LPWSTR;
            item
        };

        let new_item = TVINSERTSTRUCTW {
            hParent: parent.map(|p| p.handle ).unwrap_or(ptr::null_mut()),
            hInsertAfter: insert,
            u: item
        };

        let ptr = &new_item as *const TVINSERTSTRUCTW;
        let handle = wh::send_message(handle, TVM_INSERTITEMW, 0, ptr as LPARAM) as HTREEITEM;

        self.invalidate();

        TreeItem { handle }
    }
/// Insert a new item into the TreeView and return a reference to new newly added item
Insert a new item into the TreeView and return a reference to new newly added item
Insert a new item into the TreeView and return a reference to new newly added item
pub fn insert_item<'a>(&self, new: &'a str, parent: Option<&TreeItem>, position: TreeInsert) -> TreeItem {
        use winapi::um::commctrl::{TVM_INSERTITEMW, TVINSERTSTRUCTW, TVI_FIRST, TVI_LAST, TVI_ROOT, TVI_SORT, TVIF_TEXT};
        use winapi::um::commctrl::TVINSERTSTRUCTW_u;
        use winapi::um::winnt::LPWSTR;
        let handle = check_hwnd(&self.handle, NOT_BOUND, BAD_HANDLE);
        let insert = match position {
            TreeInsert::First => TVI_FIRST,
            TreeInsert::Last => TVI_LAST,
            TreeInsert::Root => TVI_ROOT,
            TreeInsert::Sort => TVI_SORT,
            TreeInsert::After(i) => i
        };
        let text = to_utf16(new);
        let item = {
            let mut item: TVINSERTSTRUCTW_u = unsafe { mem::zeroed() };
            let i = unsafe { item.item_mut() };
            i.mask = TVIF_TEXT;
            i.pszText = text.as_ptr() as LPWSTR;
            item
        };
        let new_item = TVINSERTSTRUCTW {
            hParent: parent.map(|p| p.handle ).unwrap_or(ptr::null_mut()),
            hInsertAfter: insert,
            u: item
        };
        let ptr = &new_item as *const TVINSERTSTRUCTW;
        let handle = wh::send_message(handle, TVM_INSERTITEMW, 0, ptr as LPARAM) as HTREEITEM;
        self.invalidate();
        TreeItem { handle }
    }
pub fn insert_item < ' a > ( & self , new : & ' a str , parent : Option < & TreeItem > , position : TreeInsert ) -> TreeItem { use winapi :: um :: commctrl :: { TVM_INSERTITEMW , TVINSERTSTRUCTW , TVI_FIRST , TVI_LAST , TVI_ROOT , TVI_SORT , TVIF_TEXT } ; use winapi :: um :: commctrl :: TVINSERTSTRUCTW_u ; use winapi :: um :: winnt :: LPWSTR ; let handle = check_hwnd ( & self . handle , NOT_BOUND , BAD_HANDLE ) ; let insert = match position { TreeInsert :: First => TVI_FIRST , TreeInsert :: Last => TVI_LAST , TreeInsert :: Root => TVI_ROOT , TreeInsert :: Sort => TVI_SORT , TreeInsert :: After ( i ) => i } ; let text = to_utf16 ( new ) ; let item = { let mut item : TVINSERTSTRUCTW_u = unsafe { mem :: zeroed ( ) } ; let i = unsafe { item . item_mut ( ) } ; i . mask = TVIF_TEXT ; i . pszText = text . as_ptr ( ) as LPWSTR ; item } ; let new_item = TVINSERTSTRUCTW { hParent : parent . map ( | p | p . handle ) . unwrap_or ( ptr :: null_mut ( ) ) , hInsertAfter : insert , u : item } ; let ptr = & new_item as * const TVINSERTSTRUCTW ; let handle = wh :: send_message ( handle , TVM_INSERTITEMW , 0 , ptr as LPARAM ) as HTREEITEM ; self . invalidate ( ) ; TreeItem { handle } }
Insert a new item into the TreeView and return a reference to new newly added item
Insert a new item into the TreeView and return a reference to new newly added item
&self
new
&'a str
parent
Option<&TreeItem>
position
TreeInsert