CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    13

    CTreeCtrl Problem

    Hi,

    I have a class dervied from the CTreeCtrl class provided by MSDN. The OnLButtonDown and the OnLButtonUp functions has been overridden.

    CMyClass:: OnLButtonDown(...)
    {
    //Do some action on the right hand pane
    // this action results in message being displayed which takes focus off from the tree structure.

    call base class implementation to get drag and drop functionality.
    CTreeCtrl::OnLButtonDown(...)
    }

    The structure of the application is that we have a tree structure on the left which links to various items on the right half of the pane. On clicking on the item in the tree, it directly goes to where it is linked on the right hand half where the user can enter text. The user has entered some text and clicks on another item in the tree structure to enter some more text under that item.

    Now, internally in the code,action is taken on the text the user has entered in the right half pane. When that action is taken, it results in a message box being displayed. The focus is taken off from the tree. So, when the base class implementation is called, the base class OnLButtonDown(...) is called which results in the system starting to drag the first tree item by assuming that the user is trying to drag and drop.

    I have tried to do a ::SetFocus(GetSafeHWnd()) just before calling the base class implementation but it does not seem to help.

    I cannot remove the call to the base class implementation because the drag and drop implementation is required which the base class provides.

    What is the action I can take to make sure that the base class does not think that the user is not trying to drag and drop?

    The action that I am expecting is that after the message box is displayed and the user clicks OK in that, the focus goes to the item in the tree that the user clicked.

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CTreeCtrl Problem

    Quote Originally Posted by sagar169 View Post
    Hi,

    I have a class dervied from the CTreeCtrl class provided by MSDN.
    It is provided by MFC.

    You should not handle anything in a mouse message handlers unless it is absolutely necessary.
    Why don’t you hadle TVN_SELCHANGED notification instead?
    See MSDN for details.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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