Tree Control Question
-
I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks
-
I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks
Handle the NM_CLICK notification. You can implement the handler in the parent dialog box or (using message reflection) in CTreeCtrl-derived class. Tomasz Sowinski -- http://www.shooltz.com.pl
-
Handle the NM_CLICK notification. You can implement the handler in the parent dialog box or (using message reflection) in CTreeCtrl-derived class. Tomasz Sowinski -- http://www.shooltz.com.pl
Thanks for your reply. I know I can use NM_CLICK, but I don't know which function in CTreeCtrl i should use. Seems liked they just return a HTREEITEM variable. The following is how i make a tree: HTREEITEM ABC, XYZ, node; ABC = m_Tree.InsertItem("ABC", TVI_ROOT); node = m_Tree.InsertItem("A", ABC); node = m_Tree.InsertItem("B", ABC); ...etc... if I want to choose B...but it returns a HTREEITEM....how can i know which "node"....
-
Thanks for your reply. I know I can use NM_CLICK, but I don't know which function in CTreeCtrl i should use. Seems liked they just return a HTREEITEM variable. The following is how i make a tree: HTREEITEM ABC, XYZ, node; ABC = m_Tree.InsertItem("ABC", TVI_ROOT); node = m_Tree.InsertItem("A", ABC); node = m_Tree.InsertItem("B", ABC); ...etc... if I want to choose B...but it returns a HTREEITEM....how can i know which "node"....
Use GetMessagePos and CTreeCtrl::HitTest. Assuming that you're handling NM_CLICK in CTreectrl-derived object, you'd write your code like this: CPoint pt = ::GetMessagePos(); ScreenToClient(&pt); UINT flags; HTREEITEM hItem; hItem = HitTest(pt, &flags); And do whatever you want with hItem and flags. Tomasz Sowinski -- http://www.shooltz.com.pl
-
I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks