Solved

Notification messages for CTreeCtrl

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
centeredAverage challenge 8 186
sum13 challenge 24 134
Problem to Office 1 45
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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