Solved

HitTest is always null in OnClick Method

Posted on 1999-01-11
3
459 Views
Last Modified: 2013-12-03
Hi,

I have handled OnClick and OnDblClick methods on the tree control. I wanted
to see if the user had clicked or double clicked on a node in the tree,
however the HitTest always returns null (as if to say there was no node
there), I know for a fact that there is and I can't figure out what is going
on...

I have used GetMessagePos() to get the coordinates of the mouse and then I
perform the hitTest.. Why is it not working....
I would appreciate any help..

Example of the OnClick Method...
LRESULT TreeView::OnClick(       
      int idCtrl,        
      LPNMHDR pnmh,        
      BOOL& bHandled)
{       
      SetCapture();       
      DWORD retVal = GetMessagePos();        
      POINTS pt = MAKEPOINTS(retVal);              
      TVHITTESTINFO lpht;       
      lpht.pt.x = pt.x;       
      lpht.pt.y = pt.y;        
      HTREEITEM hItem = TreeView_HitTest(m_ctlSysTreeView32, &lpht);       

      if(!hItem) {             
            ReleaseCapture();             
            return 0;       
      }        

      CTreeNode* pNode = FindNode(hItem);             
      if (!pNode) {             
            ReleaseCapture();             
            return 0;       
      }        

      LPDISPATCH node = pNode;        
      // Fire an event to the client MFC application       
      Fire_Click(node);       
      // Release the mouse capture.       
      ReleaseCapture();       
      return 0;
}  

Thanks In Advance  

Emma      
0
Comment
Question by:middlel
  • 2
3 Comments
 
LVL 4

Expert Comment

by:nil_dib
ID: 1418499
Didn't you forgot to call
ScreenToClient(m_ctlSysTreeView32, &lpht.pt);
before TreeView_HitTest?
0
 

Author Comment

by:middlel
ID: 1418500
arhh!!...

Thanks... How do I give the points to you??

Emma

0
 
LVL 4

Accepted Solution

by:
nil_dib earned 50 total points
ID: 1418501
:-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now