title: CTreeCtrl HitTest returning NULL MFC
body: <p>I am working on an MDI application using VS2008. I have created 2 tree conrols on a dialog box.<br>
  When I right click, 1st tree control displays a menu but 2nd tree control doesn't.<br>
  Here is my code:</p>
  
  <pre><code>BEGIN_MESSAGE_MAP(CSignalWindow, CFormView) 
  ON_NOTIFY(NM_RCLICK, IDC_TREE_PROCDATA_WR, &amp;CSignalWindow::OnNMRClickTreeProcdataWr)
  ON_NOTIFY(NM_RCLICK, IDC_TREE_PROCDATA_RD, &amp;CSignalWindow::OnNMRClickTreeProcdataRd)
  END_MESSAGE_MAP()
  
  void CSignalWindow::OnNMRClickTreeProcdataRd(NMHDR *pNMHDR, LRESULT *pResult) 
  {   
      DisplayProcDataMenuItem(true);
      *pResult = 0; 
  }
  
  void CSignalWindow::OnNMRClickTreeProcdataWr(NMHDR *pNMHDR, LRESULT *pResult) 
  {   
      DisplayProcDataMenuItem(false);
      *pResult = 0; 
  }
  
  void CSignalWindow::DisplayProcDataMenuItem(bool bInput) 
  {   
      CProcDataTreeCtrl &amp;tcProcDataRd = bInput ? m_tcProcDataRd : m_tcProcDataWr; 
      CPoint ptMousePos;  
      UINT uFlags;    
      HTREEITEM htItem;
  
      ptMousePos = (CPoint) GetMessagePos();  ScreenToClient(&amp;ptMousePos);
  
      htItem = tcProcDataRd.HitTest( ptMousePos, &amp;uFlags );
  
      if (htItem == NULL &amp;&amp; !(TVHT_ONITEM &amp; uFlags))  
      {       
          return;     
      }
  
      HTREEITEM nodSelected = tcProcDataRd.GetSelectedItem();     
      HTREEITEM parent = tcProcDataRd.GetParentItem(nodSelected);
  
      if (tcProcDataRd.GetParentItem(parent) == NULL)     
      {       
           CMenu menu;        
           CMenu* pPopup;    
      // the font popup is stored in a resource       
          if (bInput)             
               menu.LoadMenu(IDR_MENU_PROCDATA_RD); 
          else            
                menu.LoadMenu(IDR_MENU_PROCDATA_WR);      
      pPopup = menu.GetSubMenu(0);        
      ClientToScreen(&amp;ptMousePos);        
      pPopup-&gt;TrackPopupMenu( TPM_LEFTALIGN, ptMousePos.x, ptMousePos.y, this );  
      } 
  }
  </code></pre>
  
  <p>My tree control is derived from my custom class <code>CProcDataTreeCtrl</code> which is further derived from <code>CTreeCtrl</code><br>
  In case of 1st tree control,<br>
  <code>ptMousePos</code> values are fine, <code>uFlags</code> value is <code>TVHT_ONITEMLABEL</code> after calling <code>HitTest</code><br>
  In case of 2nd tree control,<br>
  <code>ptMousePos</code> values are fine, <code>uFlags</code> value is <code>TVHT_BELOW</code> and <code>HitTest</code> returning NULL.</p>
  
  <p>I am unable to understabd what is causing this problem.</p>
  
  <p>thanks for ur help,</p>
  
  <p>Nipun</p>