Jump to content

Recommended Posts

I'm new to AutoIT and am trying to use the dllcall or GuiCtrlSendMessage functions to work with Treeview and having some problems.

I can get TVM_GETCOUNT to work with either, but can't get TVM_SELECTITEM to work although it does seem to return a success code. I've even tried getting the item handle back and using it with no luck.

What am I doing wrong?

Below is the testcase built on one of the treeview examples.

#include <GUIConstants.au3>

DIM $aboutitem

DIM $treeview

GUICreate("My GUI with treeview",350,212)

CreateTree()

Func SelectTreeItem()

$treeHndle = ControlGetHandle ( "My GUI with treeview", "", $treeview )

$aboutHndle = ControlGetHandle ( "My GUI with treeview", "", $aboutitem )

$TVM_GETCOUNT = 0x1105

$TVM_SELECTITEM = 0x110b

$TVGN_FIRSTVISIBLE = 0x5

$TVGN_CARET = 0x9

$TVM_GETNEXTITEM = 0x110a

;$result = DllCall("user32.dll","int","SendMessage","hwnd",$treeHndle,"int",$TVM_GETCOUNT)

;$focusresult = ControlFocus ( "My GUI with treeview", "", $treeview )

;$result = GUICtrlSendMsg ( $treeview, $TVM_GETCOUNT , 0, 0 )

;$result = GUICtrlSendMsg ( $treeview, $TVM_SELECTITEM , $TVGN_CARET, $aboutHndle )

$result = GUICtrlSendMsg ( $treeview, $TVM_GETNEXTITEM , $TVGN_CARET, $aboutHndle )

$result = GUICtrlSendMsg ( $treeview, $TVM_SELECTITEM , $TVGN_CARET, $result )

;$result = DllCall("user32.dll","int","SendMessage","hwnd",$treeHndle,"int",$TVM_SELECTITEM,"int",$TVGN_CARET,"int",$aboutItem)

if IsArray($result) then

$resultText = ""

for $i=0 to ubound($result)-1

$resultText = $resultText & $result[$i] & @CR

next

else

$resultText = $result

endif

msgbox(0,"",$resultText)

EndFunc

Func CreateTree()

GLOBAL $treeview

$treeview = GUICtrlCreateTreeView (6,6,100,150,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

$generalitem = GUICtrlCreateTreeViewitem ("General",$treeview)

$displayitem = GUICtrlCreateTreeViewitem ("Display",$treeview)

$aboutitem = GUICtrlCreateTreeViewitem ("About",$generalitem)

$compitem = GUICtrlCreateTreeViewitem ("Computer",$generalitem)

$useritem = GUICtrlCreateTreeViewitem ("User",$generalitem)

$resitem = GUICtrlCreateTreeViewitem ("Resolution",$displayitem)

$otheritem = GUICtrlCreateTreeViewitem ("Other",$displayitem)

GuiCtrlSetState($generalitem, $GUI_EXPAND)

GuiCtrlSetState($displayitem, $GUI_EXPAND)

EndFunc

$closeButton = GUICtrlCreateButton ("Close",100,185,70,20)

$updateTreeButton = GUICtrlCreateButton ("Update",180,185,70,20)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $updateTreeButton

SelectTreeItem()

Case $msg = $GUI_EVENT_CLOSE or $msg = $closeButton

ExitLoop

EndSelect

WEnd

GUIDelete()

Exit

Link to post
Share on other sites

Sorry, not possible at the moment :lmao:

Maybe it will be implement it in one of the next beta-releases.

Then it will be (I think) possible with GUICtrlSetState($treeviewiemid,$GUI_FOCUS).

So long...

Holger

Link to post
Share on other sites

Stupid question: Why won't dllcall/SendMessage work with this but will with other functions if you're accessing the win32api directly?

AutoIT seems to be a great choice for our project, but I'm going to need control of treeview and some other UI stuff and I'm sure you guys could use some help. I personally can't contribute using C++, but I'm willing to put some resources on this if it will speed things up. Who do I need to talk to?

Thanks,

Kevin

Sorry, not possible at the moment  :lmao:

Maybe it will be implement it in one of the next beta-releases.

Then it will be (I think) possible with GUICtrlSetState($treeviewiemid,$GUI_FOCUS).

So long...

Holger

<{POST_SNAPBACK}>

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...