|
-
October 29th, 2009, 05:30 AM
#1
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.
-
November 5th, 2009, 12:40 AM
#2
Re: CTreeCtrl Problem
 Originally Posted by sagar169
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|