LerN Posted June 11, 2017 Share Posted June 11, 2017 (edited) Hi i wanted to ask some questions about the problem of the treeview i have. Here's the example i have. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <guitreeview.au3> $Form1 = GUICreate("Form1", 528, 298, 264, 115) $TreeView1 = GUICtrlCreateTreeView(8, 8, 505, 193) $Input1 = GUICtrlCreateInput("Type the name to search", 184, 216, 153, 21) $Button1 = GUICtrlCreateButton("Search", 184, 248, 155, 25) $contex = GUICtrlCreateContextMenu($TreeView1) $add = GUICtrlCreateMenuItem("Add",$contex) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($TreeView1) $first = _GUICtrlTreeView_Add($TreeView1,0,"First") for $i = 1 to 15 _GUICtrlTreeView_AddChild($TreeView1,$first,$i) Next $second = _GUICtrlTreeView_Add($TreeView1,0,"Second") for $i = 16 to 30 _GUICtrlTreeView_AddChild($TreeView1,$second,$i) Next _GUICtrlTreeView_EndUpdate($TreeView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 $searchitem = _GUICtrlTreeView_FindItem($TreeView1,GUICtrlRead($Input1),True) _GUICtrlTreeView_SelectItem($TreeView1,$searchitem) _GUICtrlTreeView_EnsureVisible($TreeView1,$searchitem) case $add $gettext = _GUICtrlTreeView_GetText($TreeView1,_GUICtrlTreeView_GetSelection($TreeView1)) GUICtrlSetData($Input1,$gettext) EndSwitch WEnd First when i right click on an item to add it to the input it back to the first one ... i know that i must first click on the item then right click but is there a way to just right click on it and get the right item ? Second i don't want to use findnext just when i click on search two times it searches for the second item is that possible ? thanks Edited June 11, 2017 by LerN Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 11, 2017 Moderators Share Posted June 11, 2017 @LerN you have been around long enough to know that you need to give meaningful titles to your posts. Everyone is looking for help, generally because they have a problem... "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
LerN Posted June 11, 2017 Author Share Posted June 11, 2017 Just now, JLogan3o13 said: @LerN you have been around long enough to know that you need to give meaningful titles to your posts. Everyone is looking for help, generally because they have a problem... Yea i noticed that after i opened the thread ... can i edit it ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 11, 2017 Moderators Share Posted June 11, 2017 Yes, just edit the first post. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
LerN Posted June 11, 2017 Author Share Posted June 11, 2017 Okay done. Link to comment Share on other sites More sharing options...
benners Posted June 11, 2017 Share Posted June 11, 2017 (edited) There's probably a better way but this is my attempt expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <guitreeview.au3> Opt('GUIOnEventMode', 1) GUICreate("Form1", 528, 298) GUISetOnEvent($GUI_EVENT_CLOSE, 'ProgramClose') Global $h_Next = 0 Global $i_TreeViewID = GUICtrlCreateTreeView(8, 8, 505, 193) Global $i_SearchInputID = GUICtrlCreateInput("Type the name to search", 184, 216, 153, 21) GUICtrlCreateButton("Search", 184, 248, 155, 25) GUICtrlSetOnEvent(-1, 'FindSelectedItem') LoadTreeView() ; load the treeview GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func FindSelectedItem() Local $h_SearchItem = _GUICtrlTreeView_FindItem($i_TreeViewID, GUICtrlRead($i_SearchInputID), True, $h_Next) _GUICtrlTreeView_SelectItem($i_TreeViewID, $h_SearchItem) _GUICtrlTreeView_EnsureVisible($i_TreeViewID, $h_SearchItem) If Not $h_SearchItem Then $h_Next = 0 MsgBox(0, 'That''s All Folks', 'All search strings found') Else $h_Next = _GUICtrlTreeView_GetNext($i_TreeViewID, $h_SearchItem) EndIf EndFunc ;==>FindSelectedItem Func LoadTreeView() _GUICtrlTreeView_BeginUpdate($i_TreeViewID) Local $i_ParentID = GUICtrlCreateTreeViewItem("First", $i_TreeViewID) For $i = 1 To 15 GUICtrlCreateTreeViewItem($i, $i_ParentID) GUICtrlSetOnEvent(-1, 'UpdateSearchBox') Next $i_ParentID = GUICtrlCreateTreeViewItem("Second", $i_TreeViewID) For $i = 16 To 30 GUICtrlCreateTreeViewItem($i, $i_ParentID) GUICtrlSetOnEvent(-1, 'UpdateSearchBox') Next _GUICtrlTreeView_EndUpdate($i_TreeViewID) EndFunc ;==>LoadTreeView Func UpdateSearchBox() If Not $h_Next Then GUICtrlSetData($i_SearchInputID, _GUICtrlTreeView_GetText($i_TreeViewID, GUICtrlRead($i_TreeViewID))) EndFunc ;==>UpdateSearchBox Func ProgramClose() Exit EndFunc ;==>ProgramClose Edited June 11, 2017 by benners Removed redundant code LerN 1 Link to comment Share on other sites More sharing options...
LerN Posted June 11, 2017 Author Share Posted June 11, 2017 What about when i right click on item it back to the first one. Link to comment Share on other sites More sharing options...
spudw2k Posted June 12, 2017 Share Posted June 12, 2017 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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