Solved

Notification messages for CTreeCtrl

Posted on 1997-03-18
1
252 Views
Last Modified: 2013-11-19
How do I get to know if the user right-clicks a item in my treectrl? (MFC 4.2)
0
Comment
Question by:koenig
1 Comment
 
LVL 1

Accepted Solution

by:
MFCGuy earned 50 total points
ID: 1300475
Add a handler for NM_RCLICK
thorugh ClassWizard.

You will get a fuction like this:
void CTheView::OnRclickTreectrl(NMHDR* pNMHDR, LRESULT* pResult)
{
      CPoint ptAction;
      GetCursorPos(&ptAction);

      CPoint ptTree=ptAction;
      ScreenToClient(&ptTree);
      CRect theRect;
      m_TreeCtrl.GetWindowRect(theRect);
      CPoint ptNew(theRect.left,theRect.top);
      ScreenToClient(&ptNew);
      ptTree.y-=ptNew.y;

      UINT nFlags;
      HTREEITEM hitemFrom = m_TreeCtrl.HitTest(ptTree, &nFlags);
      if(hitemFrom != NULL)
      {
             //do something
        }
}

I showed you the hit-testing too so you can get the HTREEITEM
of the item that was clicked...

Regards,
MFCGuy
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

13 Experts available now in Live!

Get 1:1 Help Now