Solved

HitTest is always null in OnClick Method

Posted on 1999-01-11
3
460 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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