Solved

HitTest is always null in OnClick Method

Posted on 1999-01-11
3
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

734 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