how to confirm the tree item selected
-
hi :-D what i mean is that if i clicked the item4 "---1。2--------" ,how to confirm i real did that in code. ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 路漫漫其修远兮,吾将上下而求索。
-
hi :-D what i mean is that if i clicked the item4 "---1。2--------" ,how to confirm i real did that in code. ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 路漫漫其修远兮,吾将上下而求索。
Are you talking about the
TVN_SELCHANGED
notification?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
Are you talking about the
TVN_SELCHANGED
notification?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
hi :-D what i mean is that if i clicked the item4 "---1。2--------" ,how to confirm i real did that in code. ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 路漫漫其修远兮,吾将上下而求索。
I'm not sure I understand what you want to confirm. when you click on a tree item, you will have a TVN_SELCHANGED notification ( add an handler for that ), in the handler you will receive the HTREEITEM that is selected. something like :
void MyTree::OnTreeSelchanged( NMHDR* pNMHDR, LRESULT* pResult )
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM item = pNMTreeView->itemNew.hItem;
}if you want to check for a "hardcoded" string, CTreeCtrl::GetItemText( ... ) might be what you want to check for. otherwise, I'm not certain.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
yes i am ,TVN_SELCHANGED or NM_CLICK you know the answer? please give a hint 路漫漫其修远兮,吾将上下而求索。
-
I'm not sure I understand what you want to confirm. when you click on a tree item, you will have a TVN_SELCHANGED notification ( add an handler for that ), in the handler you will receive the HTREEITEM that is selected. something like :
void MyTree::OnTreeSelchanged( NMHDR* pNMHDR, LRESULT* pResult )
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM item = pNMTreeView->itemNew.hItem;
}if you want to check for a "hardcoded" string, CTreeCtrl::GetItemText( ... ) might be what you want to check for. otherwise, I'm not certain.
Maximilien Lincourt Your Head A Splode - Strong Bad
look at this figure: ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 you know when i click the item for example item 4 which is"---1。2--------"; the question is how can i know that i clicked the item is item4 not others by code in my function OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) ? that means how to judge the item clicked is the one i want in code. your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text. 路漫漫其修远兮,吾将上下而求索。
-
-
look at this figure: ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 you know when i click the item for example item 4 which is"---1。2--------"; the question is how can i know that i clicked the item is item4 not others by code in my function OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) ? that means how to judge the item clicked is the one i want in code. your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text. 路漫漫其修远兮,吾将上下而求索。
try88 wrote: ...how can i know that i clicked the item is item4 not others by code... By looking at the
NMTREEVIEW
structure, specifically theitemNew
member. try88 wrote: your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text. What? How else are you going to add text if not dynamically? Tree controls are not populated at design/compile time. If an item has text, that text can be retrieved viaGetItemText()
. Have you looked at the documentation for how this function works?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
look at this figure: ----------------- 1 --1-------------- 2 ---1。1-------- 3 ---1。2-------- 4 ---1。3-------- 5 --2-------------- 6 ---2。1-------- 7 ---2。2-------- 8 ---2。3-------- 9 you know when i click the item for example item 4 which is"---1。2--------"; the question is how can i know that i clicked the item is item4 not others by code in my function OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) ? that means how to judge the item clicked is the one i want in code. your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text. 路漫漫其修远兮,吾将上下而求索。
HTREEITEM item = pNMTreeView->itemNew.hItem;
tells you what item you clicked on. if you add things dynamically to the tree, you will need to attach some kind of user data to each item ( or leaves ) of the tree withCTreeCtrl::SetItemData
to identify it. besides, your figure it not clear at all; what is the tree data ? what is the item number ?
Maximilien Lincourt Your Head A Splode - Strong Bad
-
try88 wrote: so sad it doesn't help Why?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
HTREEITEM item = pNMTreeView->itemNew.hItem;
tells you what item you clicked on. if you add things dynamically to the tree, you will need to attach some kind of user data to each item ( or leaves ) of the tree withCTreeCtrl::SetItemData
to identify it. besides, your figure it not clear at all; what is the tree data ? what is the item number ?
Maximilien Lincourt Your Head A Splode - Strong Bad