Solved

Notification messages for CTreeCtrl

Posted on 1997-03-18
1
267 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 66
notReplace  challenge 53 125
sumHeights2  challenge 7 102
unix example issues 18 89
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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