Tree Control
-
How to send a message to a tree control to select an item inside it( I have the handle to the tree view in my hands)?
SYAMLAL
-
How to send a message to a tree control to select an item inside it( I have the handle to the tree view in my hands)?
SYAMLAL
-
Hi,
SendMessage(hWndTreeView, TVM_SELECTITEM, ActionFlag, hTreeItem);
TVM_.... -> TreeViewMessage HTH
Hi Frank I know the prototype of send message,,,But can U explain the 4th parameter in particular.. What I am trying to do is: To automate a local ghosting tool The tool is having a window upon which the treeview resides Items in tree view: Harddisk DellUtility C: D: All these are selected by default I want to select the C: only,,and that I have to do from the code I have the handle to the tree view(Obtained using EnumChildWindows()) I think two ways of sending message is there: 1)Get handle to the item"C:" of type HTREEITEM and send a mouse click message 2)Get handle to the item "C:" of type HTREEITEM and send a select message But how to do it?????I tried in different ways ,,but no hope.... Pls help me,,,,
SYAMLAL
-
Hi Frank I know the prototype of send message,,,But can U explain the 4th parameter in particular.. What I am trying to do is: To automate a local ghosting tool The tool is having a window upon which the treeview resides Items in tree view: Harddisk DellUtility C: D: All these are selected by default I want to select the C: only,,and that I have to do from the code I have the handle to the tree view(Obtained using EnumChildWindows()) I think two ways of sending message is there: 1)Get handle to the item"C:" of type HTREEITEM and send a mouse click message 2)Get handle to the item "C:" of type HTREEITEM and send a select message But how to do it?????I tried in different ways ,,but no hope.... Pls help me,,,,
SYAMLAL
SyamlalS wrote:
,,,But can U explain the 4th parameter in particular..
Its handle to tree item. Its can be obtained using any of
CTreeCtrl
functions(GetNextItem,GetChildItem
etc,).Prasad Notifier using ATL | Operator new[],delete[][^]
-
SyamlalS wrote:
,,,But can U explain the 4th parameter in particular..
Its handle to tree item. Its can be obtained using any of
CTreeCtrl
functions(GetNextItem,GetChildItem
etc,).Prasad Notifier using ATL | Operator new[],delete[][^]
Even GETITEM,GETNEXTITEM etc requires a TVITEM parameter, which again contains a handle to tree item(hItem field),So how can I get the first item??? If I get handle to the first item I can apply GETNEXTITEM and reach at the particular(C:)item... Pls do reply Thanx to Prasad_som and Frank K and all others who are willing to reply for showing interest in my request,,,,
SYAMLAL
-
Even GETITEM,GETNEXTITEM etc requires a TVITEM parameter, which again contains a handle to tree item(hItem field),So how can I get the first item??? If I get handle to the first item I can apply GETNEXTITEM and reach at the particular(C:)item... Pls do reply Thanx to Prasad_som and Frank K and all others who are willing to reply for showing interest in my request,,,,
SYAMLAL
You already told in original post, that you have window handle, This snippet may help you to understand traversing tree control. It gets first child of root item and traverse its children.
// find root
HTREEITEM hRoot = pCtrl->GetRootItem();//pCtrl is CTreeCtrl pointerif (hRoot == NULL)
MessageBox(_T("some problem"));
else
{
}
HTREEITEM hChild = pCtrl->GetNextItem(hRoot,TVGN_CHILD)
if (pmyTreeCtrl->ItemHasChildren(hChild))
{
HTREEITEM hNextItem;
HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem(hmyItem);while (hChildItem != NULL)
{
hNextItem = pmyTreeCtrl->GetNextItem(hChildItem, TVGN_NEXT);
hChildItem = hNextItem;
}
}Prasad Notifier using ATL | Operator new[],delete[][^]
-
You already told in original post, that you have window handle, This snippet may help you to understand traversing tree control. It gets first child of root item and traverse its children.
// find root
HTREEITEM hRoot = pCtrl->GetRootItem();//pCtrl is CTreeCtrl pointerif (hRoot == NULL)
MessageBox(_T("some problem"));
else
{
}
HTREEITEM hChild = pCtrl->GetNextItem(hRoot,TVGN_CHILD)
if (pmyTreeCtrl->ItemHasChildren(hChild))
{
HTREEITEM hNextItem;
HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem(hmyItem);while (hChildItem != NULL)
{
hNextItem = pmyTreeCtrl->GetNextItem(hChildItem, TVGN_NEXT);
hChildItem = hNextItem;
}
}Prasad Notifier using ATL | Operator new[],delete[][^]
Dear Prasad,, I have the handle to the tree view and not a pointer So I can't invoke the GetRootItem function Expect ur reply..
SYAMLAL
-
Dear Prasad,, I have the handle to the tree view and not a pointer So I can't invoke the GetRootItem function Expect ur reply..
SYAMLAL
SyamlalS wrote:
I have the handle to the tree view and not a pointer
CTreeCtrl *pTreeCtrl = dynamic_cast<CTreeCtrl*> (CWnd::FromHandle(hWndYouHave));
Prasad Notifier using ATL | Operator new[],delete[][^]
-
SyamlalS wrote:
I have the handle to the tree view and not a pointer
CTreeCtrl *pTreeCtrl = dynamic_cast<CTreeCtrl*> (CWnd::FromHandle(hWndYouHave));
Prasad Notifier using ATL | Operator new[],delete[][^]
Thanx a lot ,,Prasad... dynamic cast was not required This is enough: CTreeCtrl* pCtrl = (CTreeCtrl*)(CWnd::FromHandle(HandleToTreeView)); NeWay thaks a lot again.....
SYAMLAL
-
Thanx a lot ,,Prasad... dynamic cast was not required This is enough: CTreeCtrl* pCtrl = (CTreeCtrl*)(CWnd::FromHandle(HandleToTreeView)); NeWay thaks a lot again.....
SYAMLAL
SyamlalS wrote:
dynamic cast was not required This is enough: CTreeCtrl* pCtrl = (CTreeCtrl*)(CWnd::FromHandle(HandleToTreeView));
This works, but C++ standard encourages using
dynamic_cast
or other operators(reinterpre_cast,static_cast
) . And old function style casts should be avoided wherever possible.Prasad Notifier using ATL | Operator new[],delete[][^]