I have tree control object created using CTreeCtrl MFC class. The tree control needs to support rename. When I left click on any of item in Tree the TVN_SELCHANGED event is called from which I can get the selected item of the tree as below : HTREEITEM h = m_moveListTree.GetSelectedItem(); CString s = m_moveListTree.GetItemText(h);
However when I rightclick on any item in tree I do not get any TVN_SELCHANGED event and hence my selected item still remains the same from left click event. This is causing following problem : 1)User leftclicks on item A 2)user right clicks on item B and says rename 3)Since the selected item is still A the rename is applying for item A.
Please help in solving problem.
-Praveen
I created my own MFC like home grown C++ GUI library on top of the Win32 API and looking at my code, this is how it handles that situation:
I suspect if you do something similar in the MFC right click or right button down events that will fix the problem.
NOTE: The onRightClick code above is nothing more than the handler for the WM_NOTIFY, NM_RCLICK message.