Jump to content

Search the Community

Showing results for tags 'TreeView'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum
  • AutoIt

Calendars

  • Community Calendar

Found 28 results

  1. Hello, i stuck again, Im using this function to create a treeview from root dir. ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc Folder Structure: Folder1 Folder2 Folder3 If a file exists in multiple folders, i like to color it red, if not green. I know how to do this for files, but nut for the folders. Because if there is only 1 file in Folder2 that is also in Folder1 that it should only color this single file red, inlcuding its whole tree. The Folder1 and Folder2 should be red in this case, too. Other files and trees should stay green. Edit: Basically i like to color a file and its belonging tree red if the file exists more than 1 time.
  2. Hello, im searching like 6 hours and i didnt found the right solution. Im trying to build a treeview from a directory and its subfolders etc. This function give me right treeview, but i cant color each item seperated. #include <GuiTreeView.au3> $hGui = GUICreate("Demo1", 600, 400) $hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) ListFiles_ToTreeView(@ScriptDir, 0) _GUICtrlTreeView_EndUpdate($hTreeView) Do Until GUIGetMsg() = -3 Func ListFiles_ToTreeView($sSourceFolder, $hItem) Local $sFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) EndFunc ;==>ListFiles_ToTreeView So i am searching for the exact same function just with GUICtrlCreateTreeViewItem instead of _GUICtrlTreeView_AddChild Ps: i have a folder structure where i like to color each item green if a file only exist once and red if it exist more than once. Could someone help? Solution:
  3. Hi Community, I have a problem with the usage of _GUICtrlTreeView_AddChild and setting different item text colors (and different background colors), separately for the TreeView levels. I use the UDF GUITreeViewEx.au3 of 'Melba23' and I renamed the functions to increase my understanding about the content. I already talked to him about his UDF to respect his rights and intellectual property. I read many forum threads, I tried many ways to get it, but it's seems to be impossible in the way that I use the UDF. Question: How can I set different item text colors, separately for the TreeView levels? How can I set different item background colors, separately for the TreeView levels? I found out that _GUICtrlTreeView_AddChild don't let my set this properties directly. But after loading the TreeView content I can't change the items (children) too. Only the font weight to bold I could set with _GUICtrlTreeView_SetBold but I want to do this in a generic way directly at the creation (loading) of the TreeView. Of course I tried the different functions to set text color or bkgColor, but it didn't work - maybe I do it wrong. I really hope you can help me, give me a hint and understand what I want to do. [Solved] final solution made by @LarsJ (see below) Thanks for your help - I'm grateful! Sven CODE BEFORE AFTER ExecutionPlan.zip
  4. Hello, I am struggling in merging GUITreeViewEx, Shelltristate and enhancing to handle a third state that means : some items under are selected. I have difficulties handling expand order and key Space (especially when node is collapsed). Here the zip with UDF and and example. The problem I might need some advice to handle : 1- When load Treeview, have a correct settings of the checkbox for a tristate tree 2 - Handle keyboard used for walking in tree Chicken is checked and Steak is unchecked When walking with arrow to Meat, it gets unchecked 3 - When node is collapsed and checked thru keyboard (space) the middle state is possible which should not Here is joined an animated gif showing the 3 problems Thanks for your advices GUITreeview3Ex.zip
  5. Hello, I just bumped into this problem with _GUICtrlTreeView_Sort. Just used doc example and comment out the child creation #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $aidItem[10], $iX = 9, $iY = 29, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) GUICreate("TreeView Sort", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($idTreeView) For $x = 0 To 3 $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $iX), $idTreeView) $iX -= 1 For $y = 1 To 3 ; GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iY), $aidItem[$x]) $iY -= 1 Next Next _GUICtrlTreeView_Expand($idTreeView) _GUICtrlTreeView_EndUpdate($idTreeView) MsgBox($MB_SYSTEMMODAL, "Information", "Sort") _GUICtrlTreeView_Sort($idTreeView) _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[9]) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example The tree is not sorted. There is a similar problem with deeper tree Also based on the example #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $aidItem[10], $bidItem[10], $iX = 9, $iY = 29, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) GUICreate("TreeView Sort", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($idTreeView) $index=0 For $x = 0 To 3 $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $iX), $idTreeView) $iX -= 1 For $y = 1 To 2 $BidItem[$y]= GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iY), $aidItem[$x]) $iY -= 1 For $z= 1 To 2 GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iY), $BidItem[$y]) $iY -= 1 Next Next Next _GUICtrlTreeView_Expand($idTreeView) _GUICtrlTreeView_EndUpdate($idTreeView) MsgBox($MB_SYSTEMMODAL, "Information", "Sort") _GUICtrlTreeView_Sort($idTreeView) _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[9]) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example The tree is now 2 level deep and it is not properly sorted. Any advices ? Regards
  6. I can't explain easily what i want to do, so i made a picture: What i want to do is to specify a treeview item, and then be able to move it right to be a child of the previous item, or left to do the opposite (make a child into a sibling). I also want to move and child items of the target with it, like in the bottom half of the above image depicts. However I didn't see any functions in the help file to move items around. All i want is a button that when pressed, makes the selected item and any of selected item's children move one layer to the right / left. Does anyone know how? Edit: something along the lines of _GUICtrlTreeView_Level but SET level
  7. Hi everyone. Im creating a GUI for an application. Im usinga treeview item and i want to add some information to the side of the treeview based on what cilditem you are pressing. For the moment i have a "get info" button that works. But that means that you have to select your child in the treeview, and then press a button to gte the info. I want the info to be visable as soon as you select it. With uther controls you can just add it to the loop but it doesnt seem to work with tyhe UDF version of the treeview control. Is there anything I can do? #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> ;~ Create GUI dim $guilabel[7] local $currentlevel = 1 Local $hGui = GUICreate( "Grejs", 1000, 500, 600, 300, BitOR( $GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX ) ) Local $iBorderWidth = 4, $aPos = WinGetClientSize( $hGui ) $idTV = _GUICtrlTreeView_Create($hGui, $iBorderWidth, $iBorderWidth, $aPos[0]-2*$iBorderWidth-400, $aPos[1]-2*$iBorderWidth-30 ) $root_level = _GUICtrlTreeView_Add($idTV,0,"Root") $item1 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child1") $item2 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child2") $item3 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child3") ;~ Start Gui GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idTV MsgBox(0,"","") EndSwitch WEnd GUIDelete($hGui) Exit In this example, i want the msgbox to appear whenevr i select something in the treeview. It ios not my full code, but its an example of the problam i have. Help is much appritiated /G
  8. Hey, i'm building a "Jump To" registry key function and trying to get access to the regedit treeview control like this: #include <GUIConstants.au3> #include <GuiTreeView.au3> #include <TreeViewConstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> Global $h_item ShellExecute("regedit.exe") ;~ Local $pid = ProcessExists("regedit.exe") ;~ If $pid Then ;~ $h_tree = WinHandFromPID($pid, "[CLASS:RegEdit_RegEdit]") ;~ WinActivate("[CLASS:RegEdit_RegEdit]", "") ;~ EndIf WinWaitActive("[CLASS:RegEdit_RegEdit]", "") ;~ WinActivate("[CLASS:RegEdit_RegEdit]", "") ;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_SHOW) ; activate ;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_RESTORE) ; activate ;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_RESTORE) ; activate $h_tree = WinGetHandle("[CLASS:RegEdit_RegEdit]", "") ;~ $ret = _WinAPI_ShowWindow($h_tree, @SW_RESTORE) $ctrl = ControlGetHandle($h_tree, "", "[CLASS:SysTreeView32]") ConsoleWrite("$h_tree: " & $h_tree & @CRLF) ConsoleWrite("$ctrl: " & $ctrl & @CRLF) $show = GUICtrlCreateButton("Show", 70, 180, 70, 20) Show() ;~ While 1 ;~ Sleep(200) ;~ WEnd Func Show() $result = "" _SendMessage($ctrl, $WM_SETFOCUS, 0, 0) If @error Then ConsoleWrite("error" & @CRLF) $h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_ROOT, 0) $split = StringSplit("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "\") For $i=1 To $split[0] ConsoleWrite("item bevor findkey: " & $h_item & @CRLF) $h_item = FindKey($h_item, $split[$i]) If $h_item = 0 Then Return _SendMessage($ctrl, $TVM_SELECTITEM, 0x0009, $h_item) ; expand tree _GUICtrlTreeView_Expand($ctrl, $h_item) Next MsgBox(0, "dsfsdf", "sdfsf") Exit EndFunc Func FindKey($hItemParent, $sKey) $h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItemParent) ConsoleWrite("child : " & $h_item & " key: " & $sKey & " parent: " & $hItemParent & " parent text: " & _GUICtrlTreeView_GetText($ctrl, $hItemParent) & @CRLF) While $h_item <> 0 Local $sItemText = _GUICtrlTreeView_GetText($ctrl, $h_item) ConsoleWrite("text : " & $sItemText & @CRLF) If $sItemText = $sKey Then Return $h_item $h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $h_item) ConsoleWrite("next : " & $h_item & @CRLF) WEnd ConsoleWrite("not found" & @CRLF) Return 0 EndFunc it's working, when i start regedit.exe within my app. But can't get it work when regedit.exe already open. Some ideas?
  9. So I am trying to create a file tree structure Using _FileListToArrayRec with GuiCtrlCreateTreeView. But i have some problems with levels of directorys. In my mind there is nothing wrong with my logic, but obviously it is, since i dont get the output i want Here is a printscreen of the outcome, the array is sorted so it feels like it should be pretty easy, but its not Here is the working code #include <File.au3> #include <Array.au3> #include <GUITreeview.au3> #include <WINapiSHELLEX.au3> Local $hGI = GUICreate("test", 500,500) Local $hTreeView = GUICtrlCreateTreeView(0,0,500,500) GUISetState() Local $arr = _GuictrlTreeview__FileListToArrayRec($hTreeView,"C:\Autoit\REMOVE", "*.au3||BackUp;.git*;___TrashCan") _ArrayDisplay($arr) Func _GuictrlTreeview__FileListToArrayRec($hTreeView, $sPath, $sFilter) if StringRight($sPath,1) == "\" Then $sPath = StringLeft($sPath, StringLen($sPath) - 1) if not FileExists($sPath) Then Return SetError(1,0,0) Local $aFileList = _FileListToArrayRec($sPath, $sFilter, $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) if @error Then Return SetError(1,0,0) Local $aParents[1] = [0] Local $sLastParentDirectory = False Local $hLastParentTreeItem = False Local $hLastParentChildItem = False ; Set default icons (late rreplaced with file associated icon $hImageList = _GUIImageList_Create(16, 16, 5, 1) _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList) ; Begin tree update _GUICtrlTreeView_BeginUpdate($hTreeView) For $i = 1 To $aFileList[0] Local $sCurFullFilePath = $aFileList[$i] Local $sCurFileName = _Misc_GetFileName($aFileList[$i], False) ;Get da icon Local $hIcon = _WinAPI_ShellExtractAssociatedIcon($sCurFullFilePath, 1) Local $hIcon_Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon) ;If directory If FileGetAttrib($sCurFullFilePath) == "D" Then ; Check if sub has file to add If StringLeft($sCurFullFilePath, StringLen($sLastParentDirectory)) == $sLastParentDirectory Then $hLastParentChildItem = _GUICtrlTreeView_AddChild($hTreeView, $hLastParentTreeItem, $sCurFileName, $hIcon_Index, $hIcon_Index) ;Loop will end here ContinueLoop EndIf ;Create new parent folder & Update parents $sLastParentDirectory = $sCurFullFilePath $hLastParentTreeItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("%s", $sCurFileName), $hIcon_Index, $hIcon_Index) Else If Not $hLastParentChildItem Then ;ConsoleWrite($hLastParentTreeItem&" "&$sCurFileName&@CRLF) _GUICtrlTreeView_AddChild($hTreeView, $hLastParentTreeItem, $sCurFileName, $hIcon_Index, $hIcon_Index) Else _GUICtrlTreeView_AddChild($hTreeView, $hLastParentChildItem, $sCurFileName, $hIcon_Index, $hIcon_Index) EndIf EndIf Next ; End update _GUICtrlTreeView_EndUpdate($hTreeView) Return $aFileList EndFunc Func _Misc_GetFileName($sFilePath, $KeepExtension = True) ; Gets the filename Local $StringSPlit = StringSplit($sFilePath, "\") If Not $KeepExtension Then Return StringRegExpReplace($StringSPlit[$StringSPlit[0]], "\.(.*?)[a-zA-Z1234567890_-]{1,}+", "") Return $StringSPlit[$StringSPlit[0]] EndFunc ;==>_Misc_GetFileName Any tips ? Thanks in advance
  10. This UDF can be used to make a Treeview and/or Listview able to browse Files. If you like it, please leave me a comment, also if you have any suggestions to make it better or if you found bugs. FileExplorerTreeAndListview_source.zip
  11. Hi, i am trying to create a FileManager, now i know there are better programs out there to do it, but i think its fun to try and learn nu things. Now i am getting stuck in my code i created a button to select a driver/folder after that i put's in the driver/folder contant in the TreeView, but when i select something and click on my button copy. It returns a 0 instead of something else, when i add a value to the TreeView with: GuiCtrlCreateTreeViewItem and i select that one, then my copy button works. Hope you guys can help me find out/point in the right direction where i am going wrong with this. Any pointers to a nicer GUI or a cleaner script would be appreciated Below find my code: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> ;------------------------------------------------------------------------------------------------------------------------------------------- #NoTrayIcon ;------------------------------------------------------------------------------------------------------------------------------------------- If @OSVersion = "WIN_XP" Then $OS = "Windows XP" EndIf If @OSVersion = "WIN_VISTA" Then $OS = "Windows Vista" EndIf If @OSVersion = "WIN_7" Then $OS = "Windows 7" EndIf If @OSVersion = "WIN_8" Then $OS = "Windows 8" EndIf If @OSVersion = "WIN_81" Then $OS = "Windows 8.1" EndIf ;------------------------------------------------------------------------------------------------------------------------------------------- $Form1 = GUICreate("", 615, 470, -1, -1, $WS_POPUPWINDOW) $TITLE = GUICtrlCreateLabel("FileManager", 256, 8, 103, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetState($TITLE, $GUI_DISABLE) $INFO = GUICtrlCreateLabel("Hostname:" & @TAB & @ComputerName & @CRLF & "OS:" & @TAB & @TAB & $OS, 16, 437, 200, 60) GUICtrlSetState($INFO, $GUI_DISABLE) GUICtrlCreateLabel("Source", 16, 16) $SOURCEPROGRESS = GUICtrlCreateProgress(16, 72, 289, 17, $PBS_SMOOTH) $SOURCETREE = GUICtrlCreateTreeView(16, 104, 289, 305, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) GUICtrlCreateTreeViewItem("Test1", $SOURCETREE) $SOURCEINPUT = GUICtrlCreateInput("", 16, 40, 121, 21) GUICtrlSetState($SOURCEINPUT, $GUI_DISABLE) $SELECTSOURCE = GUICtrlCreateButton("...", 144, 42, 43, 17) GUICtrlCreateLabel("Target", 568, 16) $TARGETPROGRESS = GUICtrlCreateProgress(312, 72, 289, 17, $PBS_SMOOTH) $TARGETTREE = GUICtrlCreateTreeView(312, 104, 289, 305, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $TARGETINPUT = GUICtrlCreateInput("", 480, 40, 121, 21) GUICtrlSetState($TARGETINPUT, $GUI_DISABLE) $SELECTTARGET = GUICtrlCreateButton("...", 432, 42, 43, 17) $COPY = GUICtrlCreateButton("Copy", 182, 440, 75, 25) $MOVE = GUICtrlCreateButton("Move", 270, 440, 75, 25) $DELETE = GUICtrlCreateButton("Delete", 358, 440, 75, 25) $RENAME = GUICtrlCreateButton("Rename", 446, 440, 75, 25) $CLOSE = GUICtrlCreateButton("Exit", 534, 440, 75 , 25) GUISetState(@SW_SHOW) ;------------------------------------------------------------------------------------------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $CLOSE Exit Case $SELECTSOURCE SELECTSOURCE() Case $SELECTTARGET SELECTTARGET() Case $COPY COPY() EndSwitch WEnd ;------------------------------------------------------------------------------------------------------------------------------------------- Func SELECTSOURCE() $VAR = FileSelectFolder("Select Source drive/folder", "") GUICtrlSetData($SOURCEINPUT, $VAR) Local $iWait = 10 Local $iSavPos = 0 Do For $i = $iSavPos To 100 GUICtrlSetData($SOURCEPROGRESS, $i) Sleep($iWait) $iSavPos = $i Next Until $iSavPos = 100 _GUICtrlTreeView_BeginUpdate($SOURCETREE) ListFiles_FolderSOURCE($VAR & "\", 0) _GUICtrlTreeView_EndUpdate($SOURCETREE) EndFunc ;------------------------------------------------------------------------------------------------------------------------------------------- Func SELECTTARGET() $VAR = FileSelectFolder("Select Source drive/folder", "") GUICtrlSetData($TARGETINPUT, $VAR) Local $iWait = 10 Local $iSavPos = 0 Do For $i = $iSavPos To 100 GUICtrlSetData($TARGETPROGRESS, $i) Sleep($iWait) $iSavPos = $i Next Until $iSavPos = 100 _GUICtrlTreeView_BeginUpdate($TARGETTREE) ListFiles_FolderTARGET($VAR & "\", 0) _GUICtrlTreeView_EndUpdate($TARGETTREE) EndFunc ;------------------------------------------------------------------------------------------------------------------------------------------- Func ListFiles_FolderSOURCE($SourceFolder, $Item) Local $File If StringRight($SourceFolder, 1) <> "" Then $SourceFolder &= "" Local $Search = FileFindFirstFile($SourceFolder & "*.*") If $Search = -1 Then Return While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If @extended Then ListFiles_FolderSOURCE($SourceFolder & $File, _GUICtrlTreeView_AddChild($SOURCETREE, $Item, $File)) Else _GUICtrlTreeView_AddChild($SOURCETREE, $Item, $File) EndIf WEnd FileClose($Search) EndFunc ;------------------------------------------------------------------------------------------------------------------------------------------- Func ListFiles_FolderTARGET($TargetFolder, $Item) Local $File If StringRight($TargetFolder, 1) <> "" Then $TargetFolder &= "" Local $Search = FileFindFirstFile($TargetFolder & "*.*") If $Search = -1 Then Return While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If @extended Then ListFiles_FolderTARGET($TargetFolder & $File, _GUICtrlTreeView_AddChild($TARGETTREE, $Item, $File)) Else _GUICtrlTreeView_AddChild($TARGETTREE, $Item, $File) EndIf WEnd FileClose($Search) EndFunc ;------------------------------------------------------------------------------------------------------------------------------------------- Func COPY() $VAR = GUICtrlRead($SOURCETREE) If $VAR = 0 Then MsgBox($MB_SYSTEMMODAL, "Warning!", "No item currently selected") Else $sText = GUICtrlRead($VAR, 1) ; Get the text of the treeview item If $sText == "" Then MsgBox($MB_SYSTEMMODAL, "Warning!", "Error while retrieving info about selected item") Else MsgBox($MB_SYSTEMMODAL, "FileManager", "Current item selected is: " & $sText) EndIf EndIf EndFunc ;------------------------------------------------------------------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------------------------------------------------------------------
  12. Ok, so I feel as though I am programming myself into a corner here. The code is a mess currently (but it runs) First problem: my _ScreenOffset() is basically being call in line: 189 once. This takes one of my many listviews and establishes its position relative to the client. I then use $aLV_Offset in the message loop on the $GUI_EVENT_MOUSEMOVE in an if statement. This was the only way I could figure out how to make an imaginary boundary to capture the listview I was dragging from. (any advice here would be much appreciated) Fixed Second related issue: If the user drags the whole GUI I need to update my $aLV_Offset positions and since its called once at the top - that isn't happening. I need a little nudge on how I would do this? Im thinking about registering WM_MOVE? and if the GUI moves - call my function and refresh its location. Just need a confirmation on that I suppose Third Issue: I have the drag and drop working on the Listview to the Treeview - but if you look at my Drag and Drop functions (line:379 & 400) you'll see if VERY specific to dragging FROM a list view, TO a treeview. This is the biggest hurdle right now as I need dynamic Source and Target code. case 1: If source = listview target = treeview case 2: if source = treeview target = listview There are 7 list views and 2 tree views. So its very important to me that I target the right listview and the right tree view while dragging and dropping both ways and the two controls don't handle drag and drop the same ways. So upon getting a successful drag and drop from the listviews to a treeview, I was happy! Then I thought - hmm, now... the treeview to the list view... CRAP! This is NOT written to handle it at all! I have used various examples to get this far. For example there is Treeview / Listview drag and drop code example here, but they are static. the example shows the drag and drop functions hard coded to look at one specific control and move data to another specific control. This is simple - I need something more complex. In summary - I would like some advice on best practice as I feel like I am getting into a little longer code here and at this point i feel like I put some time into going the wrong direction! haha. *Edit - Feel free to dump my include you don't have. LOL I removed the code - but didn't remove the include. DatabaseConnect.au3 #Region Includes #include <winapi.au3> #include <WinAPIEx.au3> #include <GuiToolbar.au3> #include <GuiImageList.au3> #include <GUIConstants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GUITab.au3> #include <GuiTreeView.au3> #include <Constants.au3> #include <TabConstants.au3> #include <WinAPIEx.au3> #include <DatabaseConnect.au3> #include <TreeViewConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Misc.au3> ;todo - clean out includes no longer used / remove large includes i can just replace with Const values... #EndRegion GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") #Region URL ref ;This is a site I used to trial and error finding the Id's for the Icons I wanted. ;http://diymediahome.org/windows-icons-reference-list-with-details-locations-images/ #EndRegion #Region Vars ;Only Tested on Win7 64 machine Local $fIconsLoc1 = "imageres.dll" Local $fIconsLoc2 = "Resources\Icons\Undo.ico" Global $aStrings[12] Local $iNew,$iBrowse,$iEdit,$iDelete,$iSave,$iPrint Global Enum $e_new =1000, $e_edit, $e_delete, $e_save, $e_print, $e_undo Global $iItem, $cTreeView1, $cTreeView2,$hDll, $pDll, $hProc Global $hTab1, $hTab2, $hTab3 Global $hItemHover Global $aHwndFrom, $aHwndTo Global $hTvItemHover,$hLvItemHover Global $Debugmode = True Global $aLV_Offset,$aForm_Offset,$aWin1,$aWin2 ; Icon Index from DLL $iNew = 2 ;$iBrowse = 202 $iEdit = 111 $iDelete = 84 $iSave = 23 $iPrint = 46 $iGuiWidth = 1024 $iGUIHeight = 768 $BkColor = 0xf0f0f0 #EndRegion Vars ;Create Form, Toobar and ImageList $hGui = GUICreate("EDM and CNC Schedule",$iGuiWidth,$iGUIHeight,-1,-1) GUISetState() Global $hToolbar1 = _GUICtrlToolbar_Create($hGui) $imgs = _GUIImageList_Create(32,32,5) ; change first 2 params to Size the icons accordingly. #Region Toolbar ;Populate Image List _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iNew,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iEdit,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iDelete,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iSave,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iPrint,True) _GUIImageList_AddIcon($imgs, $fIconsLoc2,0,True) ;Add Text to Buttons in Toolbar $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar1, "&New") $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar1, "&Edit") $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar1, "&Delete") $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar1, "&Save") $aStrings[4] = _GUICtrlToolbar_AddString($hToolbar1, "&Print") $aStrings[5] = _GUICtrlToolbar_AddString($hToolbar1, "&Undo") ;Set Imagelist of Toolbar to my ImageList $t = _GUICtrlToolbar_SetImageList($hToolbar1, $imgs) ;Add buttons to toolbar $cBtn_New = _GUICtrlToolbar_AddButton($hToolbar1, $e_new, 0,$aStrings[0]) $cBtn_Edit =_GUICtrlToolbar_AddButton($hToolbar1, $e_edit, 1,$aStrings[1]) $cBtn_Delete =_GUICtrlToolbar_AddButton($hToolbar1, $e_delete, 2,$aStrings[2]) $cBtn_Save =_GUICtrlToolbar_AddButton($hToolbar1, $e_save, 3,$aStrings[3]) $cBtn_Print =_GUICtrlToolbar_AddButton($hToolbar1, $e_print, 4,$aStrings[4]) $cBtn_Undo =_GUICtrlToolbar_AddButton($hToolbar1, $e_undo, 5,$aStrings[5]) GUISetState() #EndRegion Toolbar #Region Create Tabs $hGui1 = GUICreate("",$iGuiWidth-8,$iGUIHeight-65,5,60, $WS_POPUP, $WS_EX_MDICHILD,$hgui) ;~ GUISetBkColor(0x00FF00,$hGui1) ; Create top level Tab Items $hTab1 = GUICtrlCreateTab(0,1,$iGuiWidth-8,$iGUIHeight-65) $hTab1_0 = GUICtrlCreateTabItem("EDM Schedule") ;cTreeView 1 $cTreeView1 = GUICtrlCreateTreeView(0, 25, 175, 678, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;Set TreeView Data $generalitem = GUICtrlCreateTreeViewItem("16012", $cTreeView1) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("16187", $cTreeView1) GUICtrlSetColor(-1, 0x0000C0) GUICtrlCreateTreeViewItem("Stripper", $generalitem) GUICtrlCreateTreeViewItem("Die Plate", $generalitem) GUICtrlCreateTreeViewItem("Punch String", $generalitem) GUICtrlCreateTreeViewItem("Die Insert String", $displayitem) GUICtrlCreateTreeViewItem("Punch Plate", $displayitem) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold ;~ GUISetState() $hTab1_1 = GUICtrlCreateTabItem("CNC Schedule ") ;cTreeView 2 $cTreeView2 = GUICtrlCreateTreeView(0, 25, 175, 678, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $generalitem = GUICtrlCreateTreeViewItem("15874", $cTreeView2) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("16183", $cTreeView2) GUICtrlSetColor(-1, 0x0000C0) GUICtrlCreateTreeViewItem("Punch Plate", $generalitem) GUICtrlCreateTreeViewItem("Die Plate", $generalitem) GUICtrlCreateTreeViewItem("Stripper", $generalitem) GUICtrlCreateTreeViewItem("Die Shoe", $displayitem) GUICtrlCreateTreeViewItem("Punch Holder", $displayitem) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold. GUICtrlCreateTabItem("") GUISetState() ;Create Inner GUI to hold the listviews for first tab $hGuiInner1 = GUICreate("", 834,679, 182,28, $WS_POPUP,$WS_EX_MDICHILD, $hgui1) $hLabelMask1 = GUICtrlCreateLabel("",89 ,0, 760, 21, BitOR($SS_NOTIFY, $SS_CENTER)) GUICtrlsetBkColor ($hLabelMask1,0xffffff ) $hTab2 = GUICtrlCreateTab(0,0,834,679) $hTab2_0 = GUICtrlCreateTabItem("Fryer ") $ListView5 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $ListView5_0 = GUICtrlCreateListViewItem("Item1", $ListView5) $ListView5_1 = GUICtrlCreateListViewItem("Item2", $ListView5) $ListView5_2 = GUICtrlCreateListViewItem("Item3", $ListView5) $ListView5_3 = GUICtrlCreateListViewItem("Item4", $ListView5) $hTab2_1 = GUICtrlCreateTabItem("Micron") $ListView6 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $ListView6_0 = GUICtrlCreateListViewItem("Item1", $ListView6) $ListView6_1 = GUICtrlCreateListViewItem("Item2", $ListView6) $ListView6_2 = GUICtrlCreateListViewItem("Item3", $ListView6) $ListView6_3 = GUICtrlCreateListViewItem("Item4", $ListView6) GUICtrlCreateTabItem("") GUISetState() ;Create Inner GUI to hold the listviews for second tab $hGuiInner2 = GUICreate("", 834,679, 182,28, $WS_POPUP,$WS_EX_MDICHILD, $hgui1) $hLabelMask2 = GUICtrlCreateLabel("",264 , 0, 750, 21, BitOR($SS_NOTIFY, $SS_CENTER)) GUICtrlsetBkColor ($hLabelMask2,0xffffff ) $hTab3 = GUICtrlCreateTab(0,0,834,679) $hTab3_0 = GUICtrlCreateTabItem("Agie V3") $ListView7 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $ListView7_0 = GUICtrlCreateListViewItem("Item1", $ListView7) $ListView7_1 = GUICtrlCreateListViewItem("Item2", $ListView7) $ListView7_2 = GUICtrlCreateListViewItem("Item3", $ListView7) $ListView7_3 = GUICtrlCreateListViewItem("Item4", $ListView7) $hTab3_1 = GUICtrlCreateTabItem("Agie V2") $ListView8 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $hTab3_2 = GUICtrlCreateTabItem("Agie V22") $ListView9 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $hTab3_3 = GUICtrlCreateTabItem("Agie VP2") $ListView10 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) $hTab3_4 = GUICtrlCreateTabItem("Progress") $ListView11 = GUICtrlCreateListView("col1|col2|col3", 0, 20, 833, 658) GUICtrlCreateTabItem("") GUISetState() $aLV_Offset= _ScreenOffset(ControlGetHandle($hGuiInner1,"",$ListView5)) ; just to get the location of all listview (left top width hieght) #EndRegion End tabs #Region GUI Message Loop While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_MOUSEMOVE if _IsPressed("01") Then $aHwndTo = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1)) _Drag($aHwndTo[0]) if MouseGetPos(0) > $aLV_Offset[0] and MouseGetPos(1) > $aLV_Offset[1] and MouseGetPos(0) < $aLV_Offset[2] and MouseGetPos(1) < $aLV_Offset[3] then $aHwndFrom = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1)) endif endif Case $GUI_EVENT_DROPPED $aHwndTo = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1)) _Drop($aHwndTo[0],$aHwndFrom[0]) Case $GUI_EVENT_CLOSE Exit Case $htab1 Switch GUICtrlRead($htab1) Case 0 ; Adjust child GUIs accordingly GUISetState(@SW_HIDE, $hGuiInner1) GUISetState(@SW_SHOW, $hGuiInner2) Case 1 GUISetState(@SW_HIDE, $hGuiInner2) GUISetState(@SW_SHOW, $hGuiInner1) EndSwitch EndSwitch WEnd #EndRegion GUI Message Loop #Region Functions ; WM_NOTIFY event handler Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tNMHDR, $event, $hwndFrom, $icode, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld, $sButtonName, $hTreeView1, $hTreeView2 Local $tNMTOOLBAR, $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") $idFrom = DllStructGetData($tNMHDR, "IDFrom") $icode = DllStructGetData($tNMHDR, "Code") $hTreeview1 = $cTreeView1 $hTreeview2 = $cTreeView2 If Not IsHWnd($cTreeView1) Then $hTreeview1 = GUICtrlGetHandle($cTreeView1) If Not IsHWnd($cTreeView2) Then $hTreeview2 = GUICtrlGetHandle($cTreeView2) Switch $hwndFrom Case $hToolbar1 Switch $icode Case $NM_LDOWN ;case for which button was clicked Switch $iItem Case $e_new _button_Click($e_new) Case $e_edit _button_Click($e_edit) Case $e_save _button_Click($e_save) Case $e_delete _button_Click($e_delete) Case $e_print _button_Click($e_print) Case $e_undo _button_Click($e_undo) EndSwitch Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld") $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew") $iItem = $i_idNew $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") EndSwitch Case $hTreeView1, $hTreeView2 ;~ Switch $icode ;~ Case $NM_CLICK ; The user has clicked the left mouse button within the control ;~ _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; Return 1 ; nonzero to not allow the default processing ;~ Return 0 ; zero to allow the default processing ;~ Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control ;~ _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; Return 1 ; nonzero to not allow the default processing ;~ Return 0 ; zero to allow the default processing ;~ Case $NM_RCLICK ; The user has clicked the right mouse button within the control ;~ _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; Return 1 ; nonzero to not allow the default processing ;~ Return 0 ; zero to allow the default processing ;~ Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control ;~ _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; Return 1 ; nonzero to not allow the default processing ;~ Return 0 ; zero to allow the default processing ;~ Case $NM_KILLFOCUS ; control has lost the input focus ;~ _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; No return value ;~ Case $NM_RETURN ; control has the input focus and that the user has pressed the key ;~ _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; Return 1 ; nonzero to not allow the default processing ;~ Return 0 ; zero to allow the default processing ;~ ; Case $NM_SETCURSOR ; control is setting the cursor in response to a WM_SETCURSOR message ;~ ; Local $tInfo = DllStructCreate($tagNMMOUSE, $lParam) ;~ ; $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom")) ;~ ; $iIDFrom = DllStructGetData($tInfo, "IDFrom") ;~ ; $iCode = DllStructGetData($tInfo, "Code") ;~ ; _DebugPrint("$NM_SETCURSOR" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ ;~ ; "-->Code:" & @TAB & $iCode & @CRLF & _ ;~ ; "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _ ;~ ; "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _ ;~ ; "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _ ;~ ; "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _ ;~ ; "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo")) ;~ ; Return 0 ; to enable the control to set the cursor ;~ ; Return 1 ; nonzero to prevent the control from setting the cursor ;~ Case $NM_SETFOCUS ; control has received the input focus ;~ _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode, $Debugmode) ;~ ; No return value ;~ Case $TVN_BEGINDRAGA, $TVN_BEGINDRAGW ;~ _DebugPrint("$TVN_BEGINDRAG", $Debugmode) ;~ Case $TVN_BEGINLABELEDITA, $TVN_BEGINLABELEDITW ;~ _DebugPrint("$TVN_BEGINLABELEDIT", $Debugmode) ;~ Case $TVN_BEGINRDRAGA, $TVN_BEGINRDRAGW ;~ _DebugPrint("$TVN_BEGINRDRAG", $Debugmode) ;~ Case $TVN_DELETEITEMA, $TVN_DELETEITEMW ;~ _DebugPrint("$TVN_DELETEITEM", $Debugmode) ;~ Case $TVN_ENDLABELEDITA, $TVN_ENDLABELEDITW ;~ _DebugPrint("$TVN_ENDLABELEDIT", $Debugmode) ;~ Case $TVN_GETDISPINFOA, $TVN_GETDISPINFOW ;~ _DebugPrint("$TVN_GETDISPINFO", $Debugmode) ;~ Case $TVN_GETINFOTIPA, $TVN_GETINFOTIPW ;~ _DebugPrint("$TVN_GETINFOTIP", $Debugmode) ;~ Case $TVN_ITEMEXPANDEDA, $TVN_ITEMEXPANDEDW ;~ _DebugPrint("$TVN_ITEMEXPANDED", $Debugmode) ;~ Case $TVN_ITEMEXPANDINGA, $TVN_ITEMEXPANDINGW ;~ _DebugPrint("$TVN_ITEMEXPANDING", $Debugmode) ;~ Case $TVN_KEYDOWN ;~ _DebugPrint("$TVN_KEYDOWN", $Debugmode) ;~ Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW ;~ _DebugPrint("$TVN_SELCHANGED", $Debugmode) ;~ Case $TVN_SELCHANGINGA, $TVN_SELCHANGINGW ;~ _DebugPrint("$TVN_SELCHANGING", $Debugmode) ;~ Case $TVN_SETDISPINFOA, $TVN_SETDISPINFOW ;~ _DebugPrint("$TVN_SETDISPINFO", $Debugmode) ;~ Case $TVN_SINGLEEXPAND ;~ _DebugPrint("$TVN_SINGLEEXPAND", $Debugmode) ;~ EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc func _button_Click($btn_ID) Switch $btn_ID Case $e_new _DebugPrint("Clicked New button" & @LF, $Debugmode) case $e_edit _DebugPrint("Clicked Edit button" & @LF, $Debugmode) Case $e_save _DebugPrint("Clicked Save button" & @LF, $Debugmode) Case $e_delete _DebugPrint("Clicked Delete button" & @LF, $Debugmode) Case $e_print _DebugPrint("Clicked Print button" & @LF, $Debugmode) Case $e_undo _DebugPrint("Clicked Undo button" & @LF, $Debugmode) EndSwitch endfunc ;==>_button_Click Func _TreeItemFromPoint($hWnd) Local $tMPos = _WinAPI_GetMousePos(True, $hWnd) Return _GUICtrlTreeView_HitTestItem($hWnd, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) EndFunc ;==>_TreeItemFromPoint Func _Drag($hWnd) $hTvItemHover = _TreeItemFromPoint($hWnd) If $hTvItemHover = 0 Then Else ;Entered the Treeview $aRect = _GUICtrlTreeView_DisplayRect($hWnd, $hTvItemHover) $iTreeY = _WinAPI_GetMousePosY(True, $hWnd) Switch $iTreeY Case $aRect[1] To $aRect[1]+Int(($aRect[3]-$aRect[1])/4) _SendMessage($hWnd, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget $fWhere = -1 Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])/3) To $aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) _SendMessage($hWnd, $TVM_SELECTITEM, $TVGN_DROPHILITE, $hTvItemHover) ;add DropTarget $fWhere = 0 Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) To $aRect[3] _SendMessage($hWnd, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget $fWhere = 1 EndSwitch EndIf EndFunc ;==>_Drag Func _Drop($hWndTo, $hWndFrom) If $hTvItemHover <> 0 Then if _WinAPI_GetClassName($hWndFrom) = "SysListView32" then ; Get selected item in the listview $tmpItemArr = _GUICtrlListView_GetSelectedIndices($hWndFrom, TRUE) $tmpItem = _GUICtrlListView_GetItemText($hWndFrom, $tmpItemArr[1]) ; Get the selected item in the treeview $hSelected_Item = _GUICtrlTreeView_GetSelection($hWndTo) $myMSG = "Dragged: " & $tmpItem & @CRLF _ & "Dropped On: " & _GUICtrlTreeView_GetText($hWndTo, $hTvItemHover) _DebugPrint(@CRLF & $myMsg,$Debugmode) ; Reset drop target _SendMessage(GUICtrlGetHandle($hWndTo), $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget EndIf Else MsgBox(0, "", "No drop target") EndIf EndFunc ;==>_Drop Func _ScreenOffset($hWnd) $aWin1 = WinGetPos($hGuiInner1) $aWin2 = WinGetPos($hWnd) Local $tPoint = DllStructCreate("int X;int Y") local $aCoords[4] DllStructSetData($tPoint, "X", 0) DllStructSetData($tPoint, "Y", 0) _WinAPI_ClientToScreen($hWnd, $tPoint) DllStructGetData($tPoint, "X") DllStructGetData($tPoint, "Y") $aCoords[0] = $awin2[0];Left $aCoords[1] = $awin2[1];Top $aCoords[2] = $awin2[2]+$aCoords[0];Width + left $aCoords[3] = $awin2[3]+$aCoords[1];Height + Top return $aCoords EndFunc ;==>_ScreenOffset Func _DebugPrint($sText, $isEnabled, $sLine = @ScriptLineNumber) if $isenabled then ConsoleWrite(">--------------------------------" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $sText & @CRLF & _ ">--------------------------------" & @CRLF) EndIf EndFunc ;==>_DebugPrint #EndRegion functions
  13. Just very simple but universal/usefull function to get all content of TreeView from external application. It's not optimized for speed and error testing is missing, it's just for very simple code ;-) #Include <String.au3> #Include <GuiTreeView.au3> ; "C:\Program Files (x86)\Resource Kit\oleview.exe" ; COM Library Objects --> ClassMoniker $sAll = _TreeView_GetAll('OLE/COM Object Viewer', '', 'SysTreeView322') FileDelete('treeview_get_all.txt') FileWrite('treeview_get_all.txt', $sAll) ;~ClipPut($sAll) Func _TreeView_GetAll($title, $text, $classNN, $expand = False, $indent = ' ', $bullet = '') ; $bullet = '- ' $sAll = '' $hWnd = ControlGetHandle($title, $text, $classNN) If $expand Then _GUICtrlTreeView_Expand($hWnd) ; Expand All $hItem = _GUICtrlTreeView_GetFirstItem($hWnd) While $hItem <> 0x00000000 $sItem = _GUICtrlTreeView_GetText($hWnd, $hItem) $level = _GUICtrlTreeView_Level($hWnd, $hItem) $sIndent = _StringRepeat($indent, $level) $sAll &= $sIndent & $bullet & $sItem & @CRLF $hItem = _GUICtrlTreeView_GetNext($hWnd, $hItem) WEnd Return $sAll EndFunc Hope it can help somebody ...
  14. TreeView Help

    I started with a really good TreeView example from this forum and I'm incorporating it into my program. I've run into a problem correctly creating the items in the tree. I've tried several loops to achieve the desired outcome without success. I've attached a zip file containing the .au3 files and images of the incorrect/correct output. The Data array in the script is just for testing. The Treeview items need to be created dynamically. Thanks in advance for the help TreeviewEX1.zip
  15. Hi. How can I know when an item from the treeview has been checked using WM_NOTIFY function ? Items are created with _GUICtrlTreeView_Add().
  16. Hi, I recently discovered the "neoSearch" program ( '?do=embed' frameborder='0' data-embedContent>> ) and I saw it's GUI Design that is very beautyful, and I want to make a listing control like his ( I screenshoted to observe it's design ) : as you can see, that list, enlists many files and folders, but in a spaced beautyful way. How can I do that in autoit ?? He coded it in AUtoit but I can't find a dime on how to reach this design EDIT: And yes, I searched in his old posted source code, and can't determine how he managed to create that list !! Can't find any GUICtrlCreateList function. I also searched for the control's coordinates resulted by the Window Tool, but incredibly don't exist in that source code !
  17. Looking to build a TreeView dynamically from an Array (Array built from excel sheet) Have not made the excel sheet yet, so I'm open to suggestions on layout so as to make it easiest as possible to get it into a treeview. Thinking each row could be a item to add with the columns defining the placement in the trees, Like: Cells(1,1) = "Level 1 Parent Name" Cells(1,2) = "Level 2 Parent Name" Cells(1,3) = "Level 3 Parent Name" Cells(1,4) = "Add this item" Cells(1,5) = "" When value = "" then Create entire branch or any part of it that doesn't already exist. advance to next row For processing speed I'd probably want to work with an array, like: $aExcelData = _ExcelReadSheetToArray($oExcel,2,1,$LastUsedRow,$LastUsedCol) Can someone help me with the loop? or maybe point to tool that may do this?
  18. Hi there I am getting a strange issue occuring with treeview. The below code creates a three level treeview. Each top level item has subitems, so all the top level items should have a "+" before them, allowing them to be expanded. However, what is happening is that the last top level item is not showing a plus sign, until it is clicked once - then the plus sign appears. Does anyone have an idea as to why this is happening? Func _Populate_System_Treeview() local $iNumberSystems,$iCount,$iFields,$tempRecord,$tv1,$tv2,$tv3 $sSQL="Select * from tbl_systems;" If Not _EzMYSql_Query($sSQL) Then MsgBox(0, "Query Error", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) EndIf $iNumberSystems = _EzMySql_Rows() ; Number of systems (rows) in the table global $tvi[$iNumberSystems][5] for $iCount = 0 to $iNumberSystems-1 ; for each row in the table $tempRecord = _EzMySql_FetchData() ; Read the row into a temporary var for $iFields = 0 to 3 $tvi[$iCount][$iFields]=$tempRecord[$iFields] ; Fourth field reserved for pointer to treeviewbox items Next Next _ArraySort($tvi,0,0,0,0) for $iCount = 0 to $iNumberSystems-1 Switch $tvi[$iCount][2] ; SYS_level field Case 1 ; Top level $tv1=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $treeview) ; Display the item $tvi[$iCount][4]=$tv1 Case 2 ; Second level $tv2=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv1) $tvi[$iCount][4]=$tv2 Case 3 ; THird level $tv3=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv2) $tvi[$iCount][4]=$tv3 Case Else ; Should never happen ; msgbox(0,"Warning","Undefined system level detected") EndSwitch Next EndFunc
  19. Trying to use WM_COMMAND and WM_CONTEXTMENU in my GUI, and I'm having issue with the fact that WM_COMMAND doesn't fire when the mouse is over a listview or treeview. You can try to simulate my issue with the example code below. The WM_COMMAND will fire whenever the menu is created over the GUI background, but not when the menu is over the listview. #include <GuiMenu.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Enum $idOpen = 1000, $idSave, $idInfo _Main() Func _Main() ; Create GUI GUICreate("Menu", 400, 300) $hlistview = GUICtrlCreateListView("", 10, 10, 150, 280) GUISetState() ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Switch $iwParam Case $idOpen _WinAPI_ShowMsg("Open") Case $idSave _WinAPI_ShowMsg("Save") Case $idInfo _WinAPI_ShowMsg("Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Can anyone help me out with this? Thanks!
  20. I need to take control of printer option selections in a treeview, and make selections. It works fine in XP, windows 2008, vista, windows 7. But not under windows 8 64 bits. Here is what I've tried. First, to bring up the window with the treeview, 1- start Notepad. 2- Press ctrl P to bring up the print dialog. 3- Select the "Microsoft XPS Document Writer" printer. I need to make this work on other printers, but this one is a good example, and should be present on any machine. 4- click on the Preferences button. This displays the Printing Preferences dialog. 5- click on Advanced.... This displays the "Microsoft XPS Document Writer v4 Advanced Options" dialog. In has a treeview. It is viewed by the autoit window tool as a SysTreeView32 class instance. Coding attempts: Local $hwndTV = ControlGetHandle("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]") ; this succeeds and populates $hndTV ; try to find the root node Local $ItemHnd = _GuiCtrlTreeView_FindItemEx($hwndTV, "Microsoft XPS Document Writer v4 Advanced Document Settings") ; this fails and returns a "0" handle ; try to get the handle of the first item Local $FirstItemHnd = _GuiCtrlTreeView_GetFirstItem($hwndTV) ; this succeeds ; try to get the text of the first item msgbox(0,"","_GUICtrlTreeView_GetText($hwndTV, $hStart) ; this fails and returns an empty string, so that I can't step through entries looking for text ; try to use ControlTreeView Commands msgbox(0,"",ControltreeView("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]", "Exists", "#0") ; this returns 1: it can see the root node ;check if it sees children of the root node msgbox(0,"",ControltreeView("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]", "Exists", "#0|#0") ; this returns 0: it only sees a root node. This means that I can't navigate and find nodes, much less select them and make selections. I would appreciate other ideas to make those selections using AutoIT. Thanks!
  21. I added tristate to the UDF TV Explorer, but is not working right, it does not select any subfolders ... and i'm having trouble with some functions also as: MyCtrlSetItemState() MyCtrlGetItemState() CheckChildItems() *I think the problem of the tristate is here* CheckParents() *or here* TV Explorer here: and functions used to add a tristate came of this topic: Video of the problem: https://dl.dropbox.com/u/58055873/Tv%20Explorer%20Treeview.wmv the result are atacched! Can someone try to fix please? thanks and sorry for my bad English! TVExplorer Tristate.rar
  22. This UDF allows to create pseudo TreeViewTab control (tabs as TreeView). Useful for Settings dialog. Notes: Example: Download: TreeViewTab_1.2.zip TreeViewTab_1.1.zip Changelog:
  23. I want to do something like that! i tried many times but... nothing x.x i tried this topic: but this is not exactly what i want! thanks a lot!
  24. I've been having some problems adding a icon from a .dll into a treeview, Does the function _GUICtrlTreeView_SetIcon only allow you to use Shell icons or am i doing something wrong? My main script is way to large to post up so I've created a short example to illustrate my problem the resource file is attatched #include <GUITreeView.au3> #include <TreeViewConstants.au3> #include <GUIConstants.au3> Global $GUITree, $hTree $hGUI = GUICreate("Example", 500, 500, -1, -1) GUICtrlCreateLabel("Add Item Type ( 1 - 22 )", 220, 20) $hCombo = GUICtrlCreateCombo("", 220, 40, 50, 22, 0x0003) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22", "1") $hCreate = GUICtrlCreateButton("Create Tree Item", 280, 39, 100, 22) $hTree = GUICtrlCreateTreeView( 10, 10, 200, 480, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)) GUISetState() _GUICtrlTreeView_BeginUpdate($hTree) $GUITree = _GUICtrlTreeView_Add($hTree, 0, "hGUI") _GUICtrlTreeView_SetIcon($GUITree, $GUITree, @ScriptDir&"\Resources.dll", 119) _GUICtrlTreeView_EndUpdate($hTree) While 1 $hMsg = GUIGetMsg() Switch $hMsg Case -3 Exit Case $hCreate $hTreeItem = _AddTreeItem("Control Type "&GUICtrlRead($hCombo), GUICtrlRead($hCombo)) _GUICtrlTreeView_Expand($hTree) EndSwitch WEnd Func _AddTreeItem($aName, $aType) _GUICtrlTreeView_BeginUpdate($hTree) $hItem = _GUICtrlTreeView_AddChild($hTree, $GUITree, $aName) _GUICtrlTreeView_SetIcon($hTree, $hItem, @ScriptDir&"\Resources.dll", _GetIcon($aType)) _GUICtrlTreeView_EndUpdate($hTree) ConsoleWrite("+ _AddTreeItem("&$aName&", "&$aType&") Icon # "&_GetIcon($aType)&@CRLF) Return $hItem EndFunc Func _GetIcon($Type) If $Type = 1 Then Return 122 ElseIf $Type = 2 Then Return 102 ElseIf $Type = 3 Then Return 121 ElseIf $Type = 4 Then Return 114 ElseIf $Type = 5 Then Return 105 ElseIf $Type = 6 Then Return 129 ElseIf $Type = 7 Then Return 107 ElseIf $Type = 8 Then Return 123 ElseIf $Type = 9 Then Return 111 ElseIf $Type = 10 Then Return 127 ElseIf $Type = 11 Then Return 120 ElseIf $Type = 12 Then Return 128 ElseIf $Type = 13 Then Return 135 ElseIf $Type = 14 Then Return 138 ElseIf $Type = 15 Then Return 126 ElseIf $Type = 16 Then Return 136 ElseIf $Type = 17 Then Return 133 ElseIf $Type = 18 Then Return 124 ElseIf $Type = 19 Then Return 116 ElseIf $Type = 20 Then Return 113 ElseIf $Type = 21 Then Return 118 ElseIf $Type = 22 Then Return 104 EndIf EndFunc Any help would be appreciated Resources.zip
  25. I have a treeview list with checkboxes and everything is working correctly when I use the mouse to check or uncheck the item. When I use the spacebar to check or uncheck the item, it only affects the item I'm on. I need to be able to disable the spacebar or when the spacebar is pressed, call a function to set the other items checked status. Questions: 1. Can the spacebar be disabled in a treeview? 2. Can a function be called when the user presses the spacebar in a treeview? Thanks in advance.
×