ligenza Posted September 26, 2005 Share Posted September 26, 2005 (edited) Hello, would you mind looking at the following? I did my best to translate most of my comments, the code is simple enough. The concept behind the code is to select a child item in a tree view by its text, this is useful when you're recreating a treeview and controle ids are not avalible. CODE selectItembyText($c, "p3", "c1");beispiel call ;takes ArrayOfChildren, TargetsParentText, TargetsChildText) Func selectItembyText($arC, $pTxt, $cTxt) For $x = 1 to $arC[0] GUICtrlSetState($arC[$x], $GUI_FOCUS) Sleep(1000) $stxt = GUICtrlRead($arC[$x], 1) If ($stxt[0] == $cTxt) And (_tParentTxt($treeview) == $pTxt) Then Return 1 EndIf Next Return 0 EndFunc Func _tParentTxt($treeview) $hItem = GUICtrlSendMsg($treeview, 0x1100 + 10, 0x9, 0) $hParent = GUICtrlSendMsg($treeview, 0x1100 + 10, 0x3, $hItem) GUICtrlSendMsg($treeview, 0x1100 + 11, 0x9, $hParent) $cidParent = GUICtrlRead($treeview) $parent = GUICtrlRead($cidParent, 1) If Not ($parent[0] == 0) Then Return($parent[0]) Else ;Rückkehr (no parent) Return("") EndIf EndFunc Is there a better way of doing this? Mein code seems a tad messy. Ich drücke meinen Dank aus. Edit: This might be better placed in Scripts and Scraps as it works fine and I'm just seeking a better method. Edited September 29, 2005 by ligenza Link to comment Share on other sites More sharing options...
Idea Posted September 26, 2005 Share Posted September 26, 2005 Hello, would you mind looking at the following? I did my best to translate most of my comments, the code is simple enough. The concept behind the code is to select a child item in a tree view by its text, this is useful when you're recreating a treeview and controle ids are not avalible. CODEselectItembyText($c, "p3", "c1");beispiel call;takes ArrayOfChildren, TargetsParentText, TargetsChildText)Func selectItembyText($arC, $pTxt, $cTxt) For $x = 1 to $arC[0] GUICtrlSetState($arC[$x], $GUI_FOCUS) Sleep(1000) $stxt = GUICtrlRead($arC[$x], 1) If ($stxt[0] == $cTxt) And (_tParentTxt($tv) == $pTxt) Then Return 1 EndIf NextReturn 0EndFuncFunc _tParentTxt($treeview)$hItem = GUICtrlSendMsg($treeview, 0x1100 + 10, 0x9, 0)$hParent = GUICtrlSendMsg($treeview, 0x1100 + 10, 0x3, $hItem)GUICtrlSendMsg($treeview, 0x1100 + 11, 0x9, $hParent)$cidParent = GUICtrlRead($treeview)$parent = GUICtrlRead($cidParent, 1)If Not ($parent[0] == 0) Then Return($parent[0])Else ;Rückkehr (no parent)Return("")EndIfEndFuncIs there a better way of doing this? Mein code seems a tad messy. Ich drücke meinen Dank aus.Edit: This might be better placed in Scripts and Scraps as it works fine and I'm just seeking a better method.Remove the Sleep(1000). The variable names are very poor and what is all the 0x stuff in tParentTxt? Also your function depends on the number of children being in $arC[0] which is unexpected. I suggest passing a number that represents the amount of children rather then assuming that'll be in $arC[0]. [*][*][][][] - 2 stars out of five Link to comment Share on other sites More sharing options...
ligenza Posted September 26, 2005 Author Share Posted September 26, 2005 Remove the Sleep(1000). The variable names are very poor and what is all the 0x stuff in tParentTxt? Also your function depends on the number of children being in $arC[0] which is unexpected. I suggest passing a number that represents the amount of children rather then assuming that'll be in $arC[0]. [*][*][][][] - 2 stars out of fiveI didn't ask you to nitpick my code or to rate it. Is there a better way of doing this? Tweaking the function to fit your needs does not make it a better method as the general concept is the same. Feel free to modify the function as you see fit however don't tell me how I should modify my function to make you happy. To answer your 0x question I direct you to google.I'm still interested in hearing a better way of finding a child node via text in a treeview. Link to comment Share on other sites More sharing options...
Idea Posted September 26, 2005 Share Posted September 26, 2005 (edited) I didn't ask you to nitpick my code or to rate it. Tweaking the function to fit your needs does not make it a better method as the general concept is the same. Feel free to modify the function as you see fit however don't tell me how I should modify my function to make you happy. To answer your 0x question I direct you to google.I'm still interested in hearing a better way of finding a child node via text in a treeview.I understand your problem now and know the answer.Whoops! Did I just pull a JdeB? Edited September 26, 2005 by Idea Link to comment Share on other sites More sharing options...
ligenza Posted September 26, 2005 Author Share Posted September 26, 2005 Whoops! Did I just pull a JdeB? Ok. While it's nice that you're bumping my thread I'd prefer if you'd just leave. Link to comment Share on other sites More sharing options...
ligenza Posted September 28, 2005 Author Share Posted September 28, 2005 Its been a day and this is already on page four. Is it that no one cares or that no one knows? A mixture of the two..? I'm not understanding why there's zero intrest in this function apart from the forum troll bumping it a few times. Link to comment Share on other sites More sharing options...
randallc Posted September 28, 2005 Share Posted September 28, 2005 Hi, Thanks for your notes to me; i think even the best scripts have only a few interested. Try GUI forum as it seems appropriate; Generate interest with an example function which shows it actually running, perhaps (I've done a few GUI things, but not with treeview....)? Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
ligenza Posted September 29, 2005 Author Share Posted September 29, 2005 Hi,Thanks for your notes to me; i think even the best scripts have only a few interested.Try GUI forum as it seems appropriate;Generate interest with an example function which shows it actually running, perhaps (I've done a few GUI things, but not with treeview....)?Best, RandallThe caption for v3 Support includes "scripting advice for AutoIt v3." so I thought that it would be fine here. A move to GUI might be for the best though.It's not so much that I want to generate intrest in my function, I just want a review in which the method I used in the algorithm is evaluated. I am peerless. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now