Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HitTest is always null in OnClick Method

Posted on 1999-01-11
3
Medium Priority
?
477 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 200 total points
ID: 1418501
:-)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

721 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