title: CTreeCtrl setting selected item programmatically
body: <p>I want to programmatically set the state of a tree ctrl item to be selected and then process it elsewhere. I want to do this to reuse the code that is called when the user clicks it. I try this but its failing, why?</p>
  
  <pre><code>// somewhere in the code
  
  m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED);
  CommonFunction();
  
  // elsewhere
  
  CommonFunction()
  {
  HTREEITEM h = m_tree.GetSelectedItem();// this returns NULL.
  }
  </code></pre>
  
  <p>How can I do this?</p>