How to get handle of a TreeView20WndClass.?

Just starting out? Need help? Post your questions and find answers here.
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

How to get handle of a TreeView20WndClass.?

Post by dcr3 »

Hi.
Does anyone know to get the handle of a TreeView20WndClass.?


Example:

Step 1. RunProgram("progX.exe","","")

Delay(5000)

Step 2. Get the handle of the TreeView20WndClass

HWND : 00330086 : < This keeps Changing.?
Class Name : TreeView20WndClass
Class Style : CS_DBLCLKS

Step 3. Get the root node. With Right Click Button.

The root node is set as the program's name.

mouse_event_(#MOUSEEVENTF_RIGHTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_RIGHTUP,0,0,0,0)


Popupmenu with 2 Items

Step 4. Left Click Button On Item 2.To Open File.

mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to get handle of a TreeView20WndClass.?

Post by netmaestro »

I copied the example code from the TreeViewGadget and ran it. While it was running I ran this code:

Code: Select all

Global tree_hwnd.i

Procedure enumproc(hwnd, param)
  class$ = Space(255)
  GetClassName_(hwnd, @class$, 255)
  If class$ = "SysTreeView32"
    tree_hwnd = hwnd
    ProcedureReturn 0
  Else
    ProcedureReturn 1
  EndIf
EndProcedure

Repeat
  hwndparent=FindWindow_(0, "ExplorerTreeGadget")
  Delay(100)
Until hwndparent

EnumChildWindows_(hwndparent, @enumproc(), 0)

Debug Str(tree_hwnd)+" (0x"+Hex(tree_hwnd)+")"
This snippet returns the hWnd of the TreeViewGadget. It won't change. You will modify the classname from SysTreeView32 to TreeView20WndClass or whatever classname you're trying to find.
BERESHEIT
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

Re: How to get handle of a TreeView20WndClass.?

Post by dcr3 »

Thanks netmaestro .
For some reason, this doesn't work for me. :!:
netmaestro wrote: Mon Dec 06, 2021 7:29 pm You will modify the classname from SysTreeView32 to TreeView20WndClass or whatever classname you're trying to find.
Done that.

Its old VB6 prog.Over 20 yrs old. :!:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to get handle of a TreeView20WndClass.?

Post by netmaestro »

Download a program called "Greatis Windowse" and run it with your target window up. It will tell you the classname of whatever's there.
BERESHEIT
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

Re: How to get handle of a TreeView20WndClass.?

Post by dcr3 »

I already used that tool Version 5.3 and other dozen or so. :)
All of them show, TreeView20WndClass as Class Name. :evil:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to get handle of a TreeView20WndClass.?

Post by netmaestro »

Try using EnumChildWindows as I did except debug the classname and always procedurereturn 1. That will give you the class name of every child window. One of them will be some kind of treeview.
BERESHEIT
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

Re: How to get handle of a TreeView20WndClass.?

Post by dcr3 »

netmaestro wrote: Mon Dec 06, 2021 11:29 pm Try using EnumChildWindows as I did except debug the classname and always procedurereturn 1. That will give you the class name of every child window. One of them will be some kind of treeview.
I will give it another try, tomorrow, I need to rest, for now. :wink:
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

Re: How to get handle of a TreeView20WndClass.?

Post by dcr3 »

The issue was, the Progam's Title has an extra space between one of it's characters. :oops:

I now got the the TreeView20WndClass handle.

node_cnt=SendMessage_(tree_hwnd, #TVM_GETCOUNT, 0, 0)
I can get node_cnt which correct.

SendMessage_(tree_hwnd, #TVM_GETITEM,0,@Item)
Can not get the Item. :!:

So, I gone lay this to bed, for a while. I got done by a space.
Post Reply