15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CTreeCtrl: No visual feedback

Fredrik Gunne -- fge@ada.agema.se
Wednesday, January 10, 1996

This is my situation:

One overriden CTreeCtrl called CBrowseCtrl.

In CBrowseCtrl::Init // called after the control is created:
{
	HTREEITEM hSelect = FillTreeCtrl(); // Builds the tree control
					   // and returns item to be selected
	Select(hSelect);
}

The calls seems to succed, since the tree is expanded so that hSelect is visible.
But there is nothing else that shows me that the item has been selected, i.e.
the text of that item is not inverted.

Since I've also overridden OnChildNotify, I notice that I do get the TVN_SELCHANGED
message.

I think I've seen this beeing discussed here before, but I can't remember what
the solution was.

Any ideas?
Fredrik





Ken Freeman -- kfreeman@viewlogic.com
Thursday, January 11, 1996

Fredrik Gunne wrote:
> 
> This is my situation:
> 
> One overriden CTreeCtrl called CBrowseCtrl.
> 
> In CBrowseCtrl::Init // called after the control is created:
> {
>         HTREEITEM hSelect = FillTreeCtrl(); // Builds the tree control
>                                            // and returns item to be selected
>         Select(hSelect);
> }
> 
> The calls seems to succed, since the tree is expanded so that hSelect is visible.
> But there is nothing else that shows me that the item has been selected, i.e.
> the text of that item is not inverted.
> 
> Since I've also overridden OnChildNotify, I notice that I do get the TVN_SELCHANGED
> message.
> 
> I think I've seen this beeing discussed here before, but I can't remember what
> the solution was.
> 
> Any ideas?
> Fredrik

Try creating the control with TVS_SHOWSELALWAYS style.

Ken



Melson Employee -- jwallenf@interaccess.com
Monday, January 15, 1996

[Mini-digest: 2 responses]

At 10:34 AM 1/11/96 -0500, you wrote:
>Fredrik Gunne wrote:
>> 
>> This is my situation:
>> 
>> One overriden CTreeCtrl called CBrowseCtrl.
>> 
>> In CBrowseCtrl::Init // called after the control is created:
>> {
>>         HTREEITEM hSelect = FillTreeCtrl(); // Builds the tree control
>>                                            // and returns item to be selected
>>         Select(hSelect);
>> }
>> 
>> The calls seems to succed, since the tree is expanded so that hSelect is
visible.
>> But there is nothing else that shows me that the item has been selected, i.e.
>> the text of that item is not inverted.
>> 
>> Since I've also overridden OnChildNotify, I notice that I do get the
TVN_SELCHANGED
>> message.
>> 
>> I think I've seen this beeing discussed here before, but I can't remember
what
>> the solution was.
>> 
>> Any ideas?
>> Fredrik
>
>Try creating the control with TVS_SHOWSELALWAYS style.
>
>Ken
>
>

If you like, change the Select() call to CTreeCtrl::SetItemState(hSelect,
TRUE, TVIS_SELECTED) [check the flag value please] and force the selection
state.

Jason
John A. King
jking @interaccess.com

"Remember, Arthur, that evil is bad and good.....isn't!" - The Tick

-----From: nitink@sherpa.com

     I think that the solution is to use the method "CTreeCtrl::SelectItem" 
     instead of "CTreeCtrl::Select" in your code fragment below.  [Unless, 
     of course, you have your own overridden method called Select.]  
     
     In MFC 4, the "CTreeCtrl::Select" method takes two parameters, 
     HTREEITEM and a UINT that indicates the type of action to be taken; 
     whereas the SelectItem method takes only the HTREEITEM, and does 
     exactly what I think you had in mind in your code.
     
     I have used SelectItem in a Tree Control that I have, without any 
     problems.
     
     Also, the  TVS_SHOWSELALWAYS style causes a selected item to remain 
     selected when the tree-view control loses focus; but normal selection 
     should work even without it.
     
     
     
     Nitin Karandikar





| Вернуться в корень Архива |