Getting item selected in CTreeCtrl when right button clicked 
Author Message
 Getting item selected in CTreeCtrl when right button clicked
Hello,
I'm using a CTreeCtrl. I want to display a popup menu when the right
button is pressed. This menu must be different if I click on the parent
item or on the child item. I have tried to catch the right press button
event with the OnSelchangedTree and with the OnRclickTree function.

On the OnSelchangedTree, when I push the left button, I get the right
HTREEITEM value, but when I push the right button, I always get the same
HTREEITEM value (and it's the first Item in my CTreeCtrl) whatever tree
item clicked on.
With the OnRclickTree function, I always get the same HTREEITEM. I've
tried to look on the sample from MSDN but I didn't find an example that
do for the right button click.

Anyone can help?
Thanks

OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{

 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

 HTREEITEM hSelectedItem = pNMTreeView->itemNew.hItem;

// or  HTREEITEM hTreeItem = m_treeCtrl.GetSelectedItem();
...
...

Quote:
}

OnRclickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
 // TODO: Add your control notification handler code here

 HTREEITEM hTreeItem = m_treeCtrl.GetSelectedItem();
...
...

Quote:
}




Tue, 13 Feb 2001 03:00:00 GMT  
 Getting item selected in CTreeCtrl when right button clicked
You will find the solution at the following URL.

 http://www.codeguru.com/treeview/right_button_menu.shtml

Quote:

> Hello,
> I'm using a CTreeCtrl. I want to display a popup menu when the right
> button is pressed. This menu must be different if I click on the parent
> item or on the child item. I have tried to catch the right press button
> event with the OnSelchangedTree and with the OnRclickTree function.

> On the OnSelchangedTree, when I push the left button, I get the right
> HTREEITEM value, but when I push the right button, I always get the same
> HTREEITEM value (and it's the first Item in my CTreeCtrl) whatever tree
> item clicked on.
> With the OnRclickTree function, I always get the same HTREEITEM. I've
> tried to look on the sample from MSDN but I didn't find an example that
> do for the right button click.

> Anyone can help?
> Thanks

> OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
> {

>  NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

>  HTREEITEM hSelectedItem = pNMTreeView->itemNew.hItem;

> // or  HTREEITEM hTreeItem = m_treeCtrl.GetSelectedItem();
> ...
> ...
> }

> OnRclickTree(NMHDR* pNMHDR, LRESULT* pResult)
> {
>  NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
>  // TODO: Add your control notification handler code here

>  HTREEITEM hTreeItem = m_treeCtrl.GetSelectedItem();
> ...
> ...
> }



Tue, 13 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Root item not getting selected on clicking on it in CTreeCtrl

2. Root item not getting selected on clicking on it in CTreeCtrl

3. CTreeCtrl: how to determine the item number on a right click

4. Choosing item in ctreectrl by right-clicking ??

5. Q: MS VC4.2 Tree Control : Selecting item with right mouse click

6. Select Listbox item by right (!)mouse button pressing

7. Help: Detect when right button is clicked above a button

8. CTreeCtrl : how to select an item with the right click?

9. Right click in CtreeCtrl

10. CTreeCtrl Right Click Event

11. CTreeCtrl, right click

12. Right Click On CTreeCtrl

 

 
Powered by phpBB® Forum Software