Jump to content

September

Active Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by September

  1. Thank you Nine.
  2. Hi piexlsearch, Thanks, but if using the "listview", I have to change a lot of script and it might cause other issues. Still thinking how to implement it on "list".
  3. Can "GUICtrlCreateList" make below effect? Items are marked with alternate background color.
  4. Seems the $LBS_NOINTEGRALHEIGHT is the solution.
  5. If you are sizing the window size in vertical, you can see the LIST control is leaping, how to make it smooth ike the LISTVIEW control? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("My GUI list", 300, 300, -1, -1, _ BitOR($WS_MINIMIZEBOX, $WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER, $WS_THICKFRAME), _ BitOR($WS_EX_APPWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) Local $idMylist = GUICtrlCreateList("This is List", 0, 0, 148, 270) Local $idListview = GUICtrlCreateListView("This is ListView ", 152, 0, 148, 270) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Exit EndSwitch WEnd EndFunc ;==>Example
  6. Great, that's what I need, thanks.
  7. I have two tabs, which are TAB_1 and TAB_2, there are two EDIT controls, one in TAB_1, another in TAB_2, respectively. My question is, how to know which EDIT control is active?---I mean, to know which one is in front? I tried GUICtrlGetState, but two EDIT controls return 80, I also tried GUICtrlRead($tab), but nothing return.
  8. Yes, I referred the 3) Semi-Virtual, as it's faster to build a treeview from a big txt file. the 4) virtual Treeview.au3 seems has some issues, if the .txt items like: The 2|001|0|20 and its child will lose. Also, the .txt file column 2, which is indicating how many child items under the parent, but if the original .txt format is below, it's hard to figure out the count in column 2, I don't have any idea to transfer it so far. aaaaaaaaaa bbbbbbbbbbb cccccccccc ddddddddddddddd eeeeeeeeeeeeee ffffffffffffff gggggggggggg hhhhhhhhhhhh iiiiiiiiiiii jjjjjjjjjjjj kkkkkkkkkkkk llllllllllll nnnnnnnnnnnn
  9. LarsJ has a good example for coloring the items. Maybe can be referred.
  10. I tested it with a large txt file, when there are many items matching the search, it is impacting the search speed.😀
  11. Great, both are working. Now I'm thinking how to remove the duplicate first row at treeview, and how to highlight and expand the search items at treeview?
  12. Thank you all. @pixelsearch, yes, it's very fast now, but for this declaration $aPath[0] = "Root" however, if the Treefile.txt first few rows are : (This is a common situation in my daily work, and I can't change every original file to start with "root") 0#hello 0#Root 1#abgajvqduj 1#abhrheeufg 1#abiyjmwrxk ..... something interesting happens, see the Row0, it's "Root", not "hello", yes, this is due to $aPath[0]="Root", it will lose some items in the full path, see the Row 68, actually it should be \Root\abutrygviv\agvyidwsak
  13. SQLite is a bit complex, I think "_ArraySearch" is what I wanted, still need to solve the loop through and look up each item, if it has more items are matching. But the big problem is to return the whole path which is including the searched item from the treeview, it takes too much time. Do you have any idea to make it faster?
  14. I see this func can be used for comparing/searching, but the keyword must be 100% matching with the item, otherwise it returns failure. Is it possible to change? ; Returns true if a specified key exists in the Dictionary object, false if it does not. Func _ItemExists($v_key) Return $oDictionary.Exists ($v_key) EndFunc ;==>_ItemExists
  15. Sorry I'm a beginner and don't know how to use the scripting dictionary, could you help on the script? @Nine @KaFu Another question is, is it possible to highlight the result on treeview? Thanks.
  16. But how to show the full path (root,parent,child) result?
  17. Hi guys, I need to search some key words in treeview, this treeview contains 10000 or up to 100000 lines, but I found that it's too slow to retrieve the result, I need the item and its full path result. Can we: Speed up the searching? Stop the searching progress if I want? Highlight the result item(s) in the treeview? Expand the result item(s) in the treeview? Have a progress control to see the search progress? For example, if you search "zcyrjgwafv" in my script, it takes some seconds, it's too slow, if you search "zc", it's killing me #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <ListviewConstants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <ProgressConstants.au3> Opt( "MustDeclareVars", 0) Opt( "GUIOnEventMode", 0) Global $tNMHDR, $hWndFrom, $iIDFrom, $iCode, $hGui Global $idTreeView, $hTreeView, $aItems, $item, $txt, $root_parent Global $msg, $show_all_file_new Global $item_handle, $txt_1, $parent_1, $root_parent_1, $fullpath_1, $compare_result Global Const $TREEVIEW_START = 1000 Showall() Func Showall() ; Create GUI $hGui = GUICreate( "Show", 400, 800, -1, -1, ($GUI_SS_DEFAULT_GUI) ) ; Create TreeView $filemenu = GUICtrlCreateMenu("File") Global $fileitem_import = GUICtrlCreateMenuItem("Import", $filemenu) $idTreeView = GUICtrlCreateTreeView( 0, 22, 400, 340, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_TRACKSELECT) ) $hTreeView = GUICtrlGetHandle( $idTreeView ) Global $searchitemBtn = GUICtrlCreateButton("Find item",5, 385, 70, 20, $BS_FLAT) Global $searchfullBtn = GUICtrlCreateButton("Find path",5, 415, 70, 20, $BS_FLAT) Global $sEARCHinput = GUICtrlCreateInput("", 80, 385, 150, 20) Global $edit_searchresult = GUICtrlCreateEdit("",5, 485,392, 290) ; Register WM_NOTIFY message handler To create the treeview item txt GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Show GUI GUISetState(@SW_SHOW, $hGui) ; Loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $fileitem_import _read_show_all_file() Case $searchitemBtn _searchitem() Case $searchfullBtn _searchpath() EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc ;read showall Mo file and transfer to #format Func _read_show_all_file() _GuiCtrlTreeView_DeleteAll($idTreeView) $show_all_file_new = FileOpen(@scriptDir &"\" &"Treefile.txt") $aItems = FileReadToArray( $show_all_file_new ) Global $iLineCount = @extended ;~ GUICtrlCreateLabel($iLineCount&"Lines", 550, 3) FileClose(@scriptDir &"\" &"Treefile.txt") ; Create TreeView structure CreateTreeView( $aItems ) ; Expand all child items ;~ _GUICtrlTreeView_Expand( $hTreeView ) EndFunc ; Create TreeView structure Func CreateTreeView( $aItems ) ; TreeView level information Local $aLevels[100][2], $iLevel = 0, $iLevelPrev = 0 ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level ; TreeView insert structure Local $tInsert = DllStructCreate( $tagTVINSERTSTRUCT ), $pInsert = DllStructGetPtr( $tInsert ) DllStructSetData( $tInsert, "InsertAfter", $TVI_LAST ) DllStructSetData( $tInsert, "Mask", $TVIF_HANDLE+$TVIF_PARAM+$TVIF_TEXT ) DllStructSetData( $tInsert, "Text", -1 ) ; $LPSTR_TEXTCALLBACK ; Add TreeView root $aLevels[$iLevel][1] = NULL DllStructSetData( $tInsert, "Param", $TREEVIEW_START ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) ; Add TreeView items For $i = 1 To UBound( $aItems ) - 1 $iLevel = StringSplit( $aItems[$i], "#", 2 )[0] If $iLevel <> $iLevelPrev Then $aLevels[$iLevel][1] = $iLevel > $iLevelPrev ? $aLevels[$iLevelPrev][0] _ ; A child of the previous level : GUICtrlSendMsg( $idTreeView, $TVM_GETNEXTITEM, $TVGN_PARENT, $aLevels[$iLevel][0] ) ; A sibling of the level $iLevelPrev = $iLevel EndIf DllStructSetData( $tInsert, "Param", $i+$TREEVIEW_START ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) Next ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level EndFunc Func _searchitem() For $i = 0 To UBound( $aItems ) - 1 Global $iLevel_item = StringSplit( $aItems[$i], "#", 2 )[1] ;~ If GUICtrlRead($sEARCHinput) <> 0 Then $compare_result = StringInStr( $iLevel_item, GUICtrlRead($sEARCHinput), 2) ;~ EndIf If $compare_result <> 0 Then ;Determine full path of selected item in TreeView $item_handle = _GUICtrlTreeView_FindItem($idTreeView, $iLevel_item) $txt_1 = _GUICtrlTreeView_GetText($idTreeView, $item_handle) Do $parent_1 = _GUICtrlTreeView_GetParentHandle($idTreeView, $item_handle) $txt_1 = _GUICtrlTreeView_GetText($idTreeView, $parent_1) & "," & $txt_1 $item_handle = $parent_1 Until $parent_1 = 0 $root_parent_1 = _GUICtrlTreeView_GetText($idTreeView, $parent_1) StringLen($root_parent_1) $fullpath_1=StringTrimLeft($txt_1,StringLen($root_parent_1)+1) GUICtrlSetData($edit_searchresult,"", 1) GUICtrlSetData($edit_searchresult,$iLevel_item&@CRLF, 1) EndIf Next EndFunc Func _searchpath() For $i = 0 To UBound( $aItems ) - 1 Global $iLevel_item = StringSplit( $aItems[$i], "#", 2 )[1] ;~ If GUICtrlRead($sEARCHinput) <> 0 Then $compare_result = StringInStr( $iLevel_item, GUICtrlRead($sEARCHinput), 2) ;~ EndIf If $compare_result <> 0 Then ;Determine full path of selected item in TreeView $item_handle = _GUICtrlTreeView_FindItem($idTreeView, $iLevel_item) $txt_1 = _GUICtrlTreeView_GetText($idTreeView, $item_handle) Do $parent_1 = _GUICtrlTreeView_GetParentHandle($idTreeView, $item_handle) $txt_1 = _GUICtrlTreeView_GetText($idTreeView, $parent_1) & "," & $txt_1 $item_handle = $parent_1 Until $parent_1 = 0 $root_parent_1 = _GUICtrlTreeView_GetText($idTreeView, $parent_1) StringLen($root_parent_1) $fullpath_1=StringTrimLeft($txt_1,StringLen($root_parent_1)+1) GUICtrlSetData($edit_searchresult,"", 1) GUICtrlSetData($edit_searchresult,$fullpath_1&@CRLF, 1) EndIf Next EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) ;For adding item's text Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Switch HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Case $hTreeView Switch DllStructGetData( $tNMHDR, "Code" ) Case $TVN_GETDISPINFOW ; Display TreeView item text Local Static $tBuffer = DllStructCreate( "wchar Text[1000]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local $tDispInfo = DllStructCreate( $tagNMTVDISPINFO, $lParam ), $sText = StringSplit( $aItems[DllStructGetData($tDispInfo,"Param")-$TREEVIEW_START], "#", 2 )[1] DllStructSetData( $tBuffer, "Text", $sText ) DllStructSetData( $tDispInfo, "Text", $pBuffer ) DllStructSetData( $tDispInfo, "TextMax", 2 * StringLen( $sText ) + 2 ) EndSwitch EndSwitch #forceref $hWnd, $iMsg, $wParam EndFunc Treefile.txt
  18. Hi Nine, Can you help to modify the script? I tried but could not get the right result. Thanks.
  19. Hi Nine, I can see that the button's ID is 3, the treeview's ID is 4, but it seems that the "Func CreateTreeView( $aItems ) returns some control ID when click on their item and conflict with the ID of GUICtrlCreatexxxx. So how to start the treeview from 1000?
  20. Hi I'm referencing of the "Semi-virtual treeview", however, if I add one button in the GUI and run the script, if I click or select the treeview item, like "3" in this example, it will trigger button pressing function, how to fix it? #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Global $idTreeView, $hTreeView, $aItems Example() Func Example() ; Create GUI Local $hGui = GUICreate( "Create Semi-Virtual TreeView From File", 400, 400, 600, 300, $GUI_SS_DEFAULT_GUI ) Local $open = GUICtrlCreateButton ("Open", 4, 300) ; Create TreeView $idTreeView = GUICtrlCreateTreeView( 4, 4, 392, 292, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) $hTreeView = GUICtrlGetHandle( $idTreeView ) ; Read level and text of TreeView items $aItems = FileReadToArray( "TreeView.txt" ) ; Create TreeView structure CreateTreeView( $aItems ) ; Expand all child items _GUICtrlTreeView_Expand( $hTreeView ) ; Register WM_NOTIFY message handler GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $open msgbox(0,"","HELLO") EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc ; Create TreeView structure Func CreateTreeView( $aItems ) ; TreeView level information Local $aLevels[100][2], $iLevel = 0, $iLevelPrev = 0 ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level ; TreeView insert structure Local $tInsert = DllStructCreate( $tagTVINSERTSTRUCT ), $pInsert = DllStructGetPtr( $tInsert ) DllStructSetData( $tInsert, "InsertAfter", $TVI_LAST ) DllStructSetData( $tInsert, "Mask", $TVIF_HANDLE+$TVIF_PARAM+$TVIF_TEXT ) DllStructSetData( $tInsert, "Text", -1 ) ; $LPSTR_TEXTCALLBACK ; Add TreeView root $aLevels[$iLevel][1] = NULL DllStructSetData( $tInsert, "Param", 0 ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) ; Add TreeView items For $i = 1 To UBound( $aItems ) - 1 $iLevel = StringSplit( $aItems[$i], "|", 2 )[0] If $iLevel <> $iLevelPrev Then $aLevels[$iLevel][1] = $iLevel > $iLevelPrev ? $aLevels[$iLevelPrev][0] _ ; A child of the previous level : GUICtrlSendMsg( $idTreeView, $TVM_GETNEXTITEM, $TVGN_PARENT, $aLevels[$iLevel][0] ) ; A sibling of the level $iLevelPrev = $iLevel EndIf DllStructSetData( $tInsert, "Param", $i ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) Next ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Switch HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Case $hTreeView Switch DllStructGetData( $tNMHDR, "Code" ) Case $TVN_GETDISPINFOW ; Display TreeView item text Local Static $tBuffer = DllStructCreate( "wchar Text[50]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local $tDispInfo = DllStructCreate( $tagNMTVDISPINFO, $lParam ), $sText = StringSplit( $aItems[DllStructGetData($tDispInfo,"Param")], "|", 2 )[1] DllStructSetData( $tBuffer, "Text", $sText ) DllStructSetData( $tDispInfo, "Text", $pBuffer ) DllStructSetData( $tDispInfo, "TextMax", 2 * StringLen( $sText ) + 2 ) EndSwitch EndSwitch #forceref $hWnd, $iMsg, $wParam EndFunc the "TreeView.txt" is: 0|0 0|1 0|2 1|3 1|This 1|is 2|6 2|a 2|very 2|nice 3|10 3|TreeView 0|, (comma) 1|13 1|indeed. 0|15
×
×
  • Create New...