CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2005
    Location
    BANGALORE ,INDIA
    Posts
    19

    Question Tree View Right Click Problem.

    Having problems about right clicking on an item in a tree control. The item
    that is clicked on is not the right one.
    If I have three items in a tree.
    Here is my problem. I click on the first item with normal click. I click on
    the third item with the right click mouse. In this event I had a messagebox
    telling me which item is selected, and this one comes out with the first
    item no mather what. I also tried to get into the OnSelchangedItemfieldtree
    function - but with no luck.

    How can I right click on the third one and get its name out of it? Does
    anyone know?
    Last edited by harshandu; April 14th, 2006 at 05:20 AM.

  2. #2
    Join Date
    Feb 2006
    Location
    Croatia - Zagreb
    Posts
    459

    Re: Tree View Right Click Problem.

    hmm... are you using GetSelectedItem()?
    You just divided by zero, didn't you?

  3. #3
    Join Date
    Dec 2005
    Location
    BANGALORE ,INDIA
    Posts
    19

    Re: Tree View Right Click Problem.

    Ya i am using.

  4. #4
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Tree View Right Click Problem.

    Take a look at this thread

  5. #5
    Join Date
    Dec 2005
    Location
    BANGALORE ,INDIA
    Posts
    19

    Re: Tree View Right Click Problem.

    Hello all,
    Thanks a lot.I solved by using following code.

    BOOL CAddASDU::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
    {
    // TODO: Add your specialized code here and/or call the base class
    if(wParam == IDC_POINTS)
    {
    NMTREEVIEW* pNMTV = (NMTREEVIEW *) lParam;
    if(pNMTV->hdr.code == NM_RCLICK)
    {
    HTREEITEM hItem = m_PointsTree.GetDropHilightItem();
    if(hItem) m_PointsTree.SelectItem(hItem);
    }
    }

    return CDialog::OnNotify(wParam, lParam, pResult);
    }

  6. #6
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: Tree View Right Click Problem.

    Just use CTreeCtrl::GetSelectedItem when handling the NM_RCLICK
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  7. #7
    Join Date
    Dec 2005
    Location
    BANGALORE ,INDIA
    Posts
    19

    Re: Tree View Right Click Problem.

    Ya jayender thats required but it isnt alone solve the problem.we need to override the onnotify function as said above.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured