Problem with CTreeCtrl
H. Mike Hu -- hhu@viewlogic.com Monday, December 30, 1996 Environment: VC++ 4.2-flat, NT 4.0 When I use CTreeCtrl and try to figure out which item is the current focus (I have multiple selections), I find out from the online help that I can use TVIS_FOCUSED bit to do the job. Unfortunately, I can not find the declaration of TVIS_FOCUSED in VC++ 4.2-flat include files. By the way, TVIS_FOCUSED was in VC++ 2.2: #define TVIS_FOCUSED 0x0001 I used this value with VC4.2 tree view control and it just didn't work. Does anyone here have idea on this? And any work around? Thanks, Mike
Thomas Schall -- schall@csv.ica.uni-stuttgart.de Thursday, January 02, 1997 Hi Mike, I had the same problem. Just use the method CTreeCtrl::GetSelectedItem() to figure which item is selected (focused). The hell knows what has been changed. Add the #define-statement of TVIS_FOCUSED to the include file. You can query for the focused item by this flag, too. A problem seems to occur when you use multi selection. Therefore I use the method I mentioned above. Maybe MS has forgotten to add the definition?!? Multi selection needs other tricks to get things working right. Have you had the nice effect when having multiple items selected and your control is hidden and reactivated again? Selected items in the hidden area appear grey. The control only updates the last focused item correctly. I used a simple Invalidate() of the control when the window is de-/activated. Thomas
H. Mike Hu -- hhu@viewlogic.com Friday, January 03, 1997 Thomas, Thanks for your help. As Katy Mulvey atpointed out, VC++ 4.2b patch fixed the TVIS_FOCUSED definition problem. After I upgraded from 4.2-flat to 4.2b, CTreeCtrl::GetSelectedItem() is the only way I can use to get current focused item. And you are right about using Invalidate() to display selected items correctly when the control is not in focus. I can not find any other way to achieve this. Mike
| Вернуться в корень Архива |