-
September 19th, 2008, 04:55 AM
#1
Getting the handle of a control from EnumChildWindows()
I have enumerated the child windows of an application. My idea is to get a pointer to the first child control of the window which is a tree control.( I have made sure it is a tree control by the Ctrl ID and the handle obtained is correct.)
Now having obtained a handle to the tree control( hWndTreeCtrl) by EnumChildWindows, I want to get a pointer to the tree control like as follows:
CTreeCtrl* pTreeCtrl = static_cast< CTreeCtrl* > ( CWnd::FromHandle( hWndTreeCtrl ));
Though I can now access the methods of CTreeCtrl using pTreeCtrl , it is not working as expected. Say , for example, pTreeCtrl->GetCount() returns different values though the item count in tree is the same always.
I also want to get the root item of the tree as follows and traverse the tree.
HTREEITEM hRoot= pTreeCtrl->GetRootItem();
hRoot = (HTREEITEM)::SendMessage(hWndTreeCtrl, TVM_GETNEXTITEM, TVGN_ROOT, 0);
But the handle returned is null.
But HTREEITEM hRoot= pTreeCtrl->GetRootItem() sems to work but when I get the text of a tree item null is returned. what could be wrong? Please help.
-
September 19th, 2008, 05:27 AM
#2
Re: Getting the handle of a control from EnumChildWindows()
Are you sure this control is a real standard tree control?
Try to check its class name (GetClassName API): for the standard tree control the class name is SysTreeView32
Victor Nijegorodov
-
September 19th, 2008, 05:34 AM
#3
Re: Getting the handle of a control from EnumChildWindows()
Yes..I checked using Spy++. The name returned is SysTreeView32.
I have observed that when we are working with a tree view control created in a vc++ app, the FromHandle() function returns correct handle.
When called from another app, it returns a temporary handle...
-
September 19th, 2008, 02:07 PM
#4
Re: Getting the handle of a control from EnumChildWindows()
You can't access tree items like this when the tree control is from another process.
If you need to manipulate tree items (from another process), look into using Active Accessibility.
-
September 19th, 2008, 04:33 PM
#5
Re: Getting the handle of a control from EnumChildWindows()
Originally Posted by Arjay
You can't access tree items like this when the tree control is from another process.
If you need to manipulate tree items (from another process), look into using Active Accessibility.
No, just use RPM
-
September 19th, 2008, 04:40 PM
#6
Re: Getting the handle of a control from EnumChildWindows()
Fred, can you be any more cryptic?
-
September 20th, 2008, 01:24 AM
#7
Re: Getting the handle of a control from EnumChildWindows()
Thank you...Yes..I think I should look into Accessibility...
-
September 20th, 2008, 01:40 AM
#8
Re: Getting the handle of a control from EnumChildWindows()
RPM = ReadProcessMemory() API
WPM = WriteProcessMemory() API.
used to modify dynamic memory that which every program is made up with.. when loaded in RAM memory
-
September 20th, 2008, 12:04 PM
#9
Re: Getting the handle of a control from EnumChildWindows()
Thanks. Those are definitly not the api's to use to solve this issue.
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
|