Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a tree control and I want to set focus on the top most item.Im using the following function but its not setting.
C++
HTREEITEM htiRoot = m_treeAvailableGraphs.GetRootItem(); 
m_treeAvailableGraphs.SetItemState(htiRoot, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);


Please suggest me how can I do this.
Thanks in advance.

What I have tried:

C++
HTREEITEM htiRoot = m_treeAvailableGraphs.GetRootItem(); 
m_treeAvailableGraphs.SetItemState(htiRoot, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
Posted
Updated 18-May-16 23:43pm

1 solution

Most likely because you are using ListView states rather than TreeView ones. See Tree-View Control Item States (Windows)[^] for the correct values.
 
Share this answer
 
Comments
cppcoder1 19-May-16 7:09am    
Thank you Richard.I have changed it but that is also not working. Is there any other way to set focus by default?
Richard MacCutchan 19-May-16 7:30am    
All information on using Windows controls is described in the documentation: see https://msdn.microsoft.com/en-us/library/windows/desktop/bb773912(v=vs.85).aspx.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900