Jump to content

Search the Community

Showing results for tags 'Treeview'.

  • 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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

  1. I have a GUI that contains a treeview and what I am trying to do is to get the context menu to only show when an item is right clicked. Currently, as it's assigned to the treeview, the context menu activates whenever the treeview is clicked. Rather than keep enabling\disabling the menu items I am in need of a way limit the menus popup. One of the options on the menu will open another GUI and disable the parent, for this reason, I cannot do much in the WM_NOTIFY portion as it hangs the program and I don't want to hang around blocking the messages. The other option is to create a menu for each treeview item when the are added to the list. This will fix the issue but there maybe 100+ items and I don't want to have that many menus all of which have the same 2/3 options. I am currently looking at using an Adlib function as mentioned here by Melba. I could create and destroy the menu each time and unregister the adlib when the function closes. Anyway, a producer code is below if there are any other ideas, or I've missed the obvious. Cheers #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <GuiTreeView.au3> #include <ButtonConstants.au3> #include <GUIListBox.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI = GUICreate("TreeView", 400, 300) Global $cTreeView = GUICtrlCreateTreeView(10, 10, 380, 280) Local $cParent = GUICtrlCreateTreeViewItem('List', $cTreeView) For $i = 1 To 5 GUICtrlCreateTreeViewItem('Item ' & $i, $cParent) Next Local $cCMenu = GUICtrlCreateContextMenu($cTreeView) Global $cCMenuEdit = GUICtrlCreateMenuItem("Edit", $cCMenu) GUICtrlSetState(-1, $GUI_DISABLE) _GUICtrlTreeView_Expand($cTreeView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cCMenuEdit EndSwitch WEnd EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $cTreeView Switch $iCode Case $NM_RCLICK Local $tPoint = _WinAPI_GetMousePos(True, $hWndFrom) Local $tHitTest = _GUICtrlTreeView_HitTestEx($hWndFrom, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2)) If BitAND(DllStructGetData($tHitTest, "Flags"), $TVHT_ONITEM) Then If _GUICtrlTreeView_Level($cTreeView, DllStructGetData($tHitTest, 'Item')) > 0 Then GUICtrlSetState($cCMenuEdit, $GUI_ENABLE) Else GUICtrlSetState($cCMenuEdit, $GUI_DISABLE) EndIf _GUICtrlTreeView_SelectItem($hWndFrom, DllStructGetData($tHitTest, 'Item')) Else GUICtrlSetState($cCMenuEdit, $GUI_DISABLE) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  2. Hi, I have developed Java maven based framework and integrated AutoIt in it. I am automated a desktop application. During automation, I am facing below issue. Can someone please guide me? 1. I am unable to select a menu option from a nested tree view: Example- TreeTitle1 TreeTitle1.1 TreeOption ToSelect In above case, TreeTitle1 is a folder in which TreeTitle2 is another folder and the TreeOptionToSelect is the one i want to select. I tried below command: AutoItX autoIt = new AutoItX(); autoIt.controlTreeViewExpand(pagetitle,"",treecontrolname,"#0|#0"); autoIt.controlTreeViewSelect(pagetitle,"",treecontrolname,"#0|#0|#0"); But it didn't work... kindly help
  3. Hi people, I'm trying to dynamically populate a TreeView based on a script from Water that I modified for my needs. but I can't figured it out how to make it work. Here what I have in case anyone can help me, thanks in advance: #include <array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> Local $aTV1[14][3] = [ _ ['1', 'Text 1', -1], _ ;-1 idicates it's an index item ['2', 'Text 2',-1], _ ['3', 'Text 3',-1], _ ['1-1', 'Text 1-1',0], _ ['1-2', 'Text 1-2',0], _ ['2-1', 'Text 2-1',0], _ ['2-2', 'Text 2-2',0], _ ['2-1-1', 'Text 2-1-1',0], _ ['2-1-2', 'Text 2-1-2',0], _ ['2-1-2-1', 'Text 2-1-2-1',0], _ ['2-1-2-1-1', 'Text 2-1-2-1-1',0], _ ['3-1', 'Text 3-1',0], _ ['3-1-1', 'Text 3-1-1',0], _ ['3-1-1-1', 'Text 3-1-1-1',0]] ;_ArrayDisplay($aTV1) Local $Gui = GUICreate('TreeView Example', 500, 600) Local $tv = GUICtrlCreateTreeView(10, 30, 450, 550) GUISetState() _pop_treeview($tv, $aTV1) While 1 Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd Func _pop_treeview($hTV, $array) Local $TimeInitial = TimerInit(), $Hours, $Mins, $Secs, $item _ArraySort($array, 0, 0, 0, 0) ;------------------------- sort Ascending on column 0 ;_ArrayDisplay($array) $idxroot = _GUICtrlTreeView_Add($hTV, 0, "index") For $i = 0 To UBound($array) - 1 ConsoleWrite("$array[" & $i & "][" & 0 & "] = " & $array[$i][0] & @CRLF) If $array[$i][0] = '' Then ExitLoop ;--------------- Exit at first empty element $item = '' If $array[$i][2] = -1 Then ;------------------------ Add root element _GUICtrlTreeView_AddChild($hTV, $idxroot, $array[$i][1]) Else $item = StringLeft($array[$i][0], StringInStr($array[$i][0], "-", 1, -1) - 1) ConsoleWrite("$item = " & $item & @CRLF) $Found = _ArrayBinarySearch($array, $item, 0, 0, 0) ;search on column 0 Switch $Found Case 0 ;----------------------------------- Value wasn't found in array ConsoleWrite("Item NOT found @error= " & @error & @CRLF) Case Else ConsoleWrite("Item found " & @CRLF) _GUICtrlTreeView_AddChild($hTV, $Found, $array[$i][1]) EndSwitch EndIf Next _GUICtrlTreeView_Expand($hTV) EndFunc ;==>_pop_treeview
  4. good morning this is the first post here in the autoit forums i hope that you can help me in my problem i have a JSON encoded it a map of my forums where i want to make a treeview that have the same type of map e.g a system (as category) windows (as sub category) software (as an child item in the windows category) ..... i don't know how to do that so, i know that i can do that using the json functions but i need your help about how we can do it as the type that i told you by the way i need to put the sub info for each item in an array that give me the ability to manage my items e.g can post thread can reply message cound ... you just give me a small example and i can continue. am sorry if this against the rules of the forum. but i realy searched a lot but i couldn't i hope some one give me the way. thank you very much in advance here is the link of json forum https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/ and here is my encoded json file { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }
  5. Hello, I am having great difficulty with something I would have thought to be fairly easy. I have an array containing (military) organization strings, similar to this: 42nd Battalion Company A 1st Platoon 1st Squad 2nd Squad 3rd Squad 2nd Platoon ...1st, 2nd, 3rd Squad 3rd Platoon ...1st, 2nd, 3rd Squad Company B ...etc... I also have an associated array that contains the 'hierarchy' information associated with each string..."0", "1","2", etc ...therefore using example above the "0" would associate with "42nd Battalion", while "1" would be "Company A", "2" is "1st Platoon", etc. Each sequential number is a 'child' of the preceding number. Therefore the information above would appear in the array as "0", "1", "2", "3", "3", "3", "2", "3", "3", "3", "2", "3", "3", "3", "1", etc... My issue is that I'm having great difficulty creating a 'Treeview' control using this information. Mainly due to the fact that entries can, and will...repeat (for example multiple entries for "Company A", "Company B", "1st Platoon", "1st Squad", etc, etc). The following code is operative, however it does not create the treeview items as 'child' entries of one another...it simply lists each item as a separate entity. For $_populate = 0 to Ubound($_HIERARCHY) - 1 _GUICtrlTreeView_BeginUpdate($idTreeView) _GUICtrlTreeView_Add($idTreeView, $_HIERARCHY[$_populate], String($_STRUCTURES[$_populate])) _GUICtrlTreeView_EndUpdate($idTreeView) Next ;Next $_populate, cycle thru '$_HIERARCHY' array to build 'TREEVIEW' Controls As I mentioned earlier I thought I could manage this...however i'm pulling out quite a bit of my hair trying to get this working properly...any help would be appreciated. I thank you in advance.
  6. 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.
  7. 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:
  8. 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
  9. 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
  10. 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
  11. 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:
  12. 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
  13. 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
  14. 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?
  15. 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 ...
  16. 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
  17. 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
  18. 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
  19. 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 ;------------------------------------------------------------------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------------------------------------------------------------------
  20. 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
  21. LAST VERSION - 1.3 28-Jan-15 Unlike >this, here is a fully ready UDF library. The library allows you to create TreeView (TV) Explorer controls that displays a tree of files and folders for the specified root folder with the specified parameters. TV Explorer controls is self-contained GUI controls that do not require you any further doing. Note that TVExplorer UDF requires >WinAPIEx UDF version 3.3 or later. To create TV Explorer control, just call the _GUICtrlTVExplorer_Create() function. And that's it. If you want to be notified about events such as the changing selection, the beginning and ending of the updating TV Explorer control, mounting and unmounting removeable drives, etc., you must specify a user function to retrieve these notifications, like WM-functions. How it works is shown in the following example. This library can work in "Loop" and "OnEvent" GUI modes. If the "GUIOnEventMode" option is set to 0, you should use _GUICtrlTVExplorer_GetMsg() instead of native GUIGetMsg() function, otherwise, the TV Explorer controls will not work. In using, these two functions are completely equivalent. A more detailed description of all functions you'll find inside the library. Available functions TVExplorer UDF Library v1.2 Previous downloads: 2266 TVExplorer.zip Example 1 #Include <APIConstants.au3> #Include <GUIConstantsEx.au3> #Include <GUITreeView.au3> #Include <TVExplorer.au3> #Include <TreeViewConstants.au3> #Include <WindowsConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $Path, $Style If Not _WinAPI_DwmIsCompositionEnabled() Then $Style = $WS_EX_COMPOSITED Else $Style = -1 EndIf $hForm = GUICreate('TVExplorer UDF Example', 700, 736, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style) GUISetIcon(@WindowsDir & '\explorer.exe') $Input[0] = GUICtrlCreateInput('', 20, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[1] = GUICtrlCreateInput('', 360, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[2] = GUICtrlCreateInput('', 20, 378, 660, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') For $i = 0 To 2 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i])) _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i]) Next $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO') GUIRegisterMsg($WM_SIZE, 'WM_SIZE') HotKeySet('{F5}', '_TVRefresh') GUISetState() _GUICtrlTVExplorer_Expand($hTV[0], @ProgramFilesDir & '\AutoIt3') _GUICtrlTVExplorer_Expand($hTV[1]) While 1 Switch _GUICtrlTVExplorer_GetMsg() Case $GUI_EVENT_CLOSE GUIDelete() _GUICtrlTVExplorer_DestroyAll() Exit Case $Dummy $Path = _GUICtrlTVExplorer_GetSelected($hFocus) _GUICtrlTVExplorer_AttachFolder($hFocus) _GUICtrlTVExplorer_Expand($hFocus, $Path, 0) $hFocus = 0 EndSwitch WEnd Func _TVEvent($hWnd, $iMsg, $sPath, $hItem) Switch $iMsg Case $TV_NOTIFY_BEGINUPDATE GUISetCursor(1, 1) Case $TV_NOTIFY_ENDUPDATE GUISetCursor(2) Case $TV_NOTIFY_SELCHANGED For $i = 0 To 2 If $hTV[$i] = $hWnd Then _TVSetPath($Input[$i], $sPath) ExitLoop EndIf Next Case $TV_NOTIFY_DBLCLK ; Nothing Case $TV_NOTIFY_RCLICK ; Nothing Case $TV_NOTIFY_DELETINGITEM ; Nothing Case $TV_NOTIFY_DISKMOUNTED ; Nothing Case $TV_NOTIFY_DISKUNMOUNTED ; Nothing EndSwitch EndFunc ;==>_TVEvent Func _TVSetPath($iInput, $sPath) Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2) If GUICtrlRead($iInput) <> $Text Then GUICtrlSetData($iInput, $Text) EndIf EndFunc ;==>_TVSetPath Func _TVRefresh() Local $hWnd = _WinAPI_GetFocus() For $i = 0 To 2 If $hTV[$i] = $hWnd Then If Not $hFocus Then $hFocus = $hWnd GUICtrlSendToDummy($Dummy) EndIf Return EndIf Next HotKeySet('{F5}') Send('{F5}') HotKeySet('{F5}', '_TVRefresh') EndFunc ;==>_TVRefresh Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam) Switch $hWnd Case $hForm DllStructSetData($tMMI, 'MinTrackSize', 428, 1) DllStructSetData($tMMI, 'MinTrackSize', 450, 2) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_GETMINMAXINFO Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) Local $WC, $HC, $WT, $HT Switch $hWnd Case $hForm $WC = _WinAPI_LoWord($lParam) $HC = _WinAPI_HiWord($lParam) $WT = Floor(($WC - 60) / 2) $HT = Floor(($HC - 116) / 2) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[0]), 20, 48, $WT, $HT) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[1]), $WT + 40, 48, $WC - $WT - 60, $HT) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[2]), 20, $HT + 96, $WC - 40, $HC - $HT - 116) GUICtrlSetPos($Input[0], 20, 20, $WT) GUICtrlSetPos($Input[1], $WT + 40, 20, $WC - $WT - 60) GUICtrlSetPos($Input[2], 20, $HT + 68, $WC - 40) For $i = 0 To 2 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i])) Next Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Example 2 (OnEvent mode) #Include <APIConstants.au3> #Include <GUIConstantsEx.au3> #Include <GUITreeView.au3> #Include <TVExplorer.au3> #Include <TreeViewConstants.au3> #Include <WindowsConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Opt('GUIOnEventMode', 1) Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $Style If Not _WinAPI_DwmIsCompositionEnabled() Then $Style = $WS_EX_COMPOSITED Else $Style = -1 EndIf $hForm = GUICreate('TVExplorer UDF Example', 700, 736, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style) GUISetOnEvent($GUI_EVENT_CLOSE, '_GUIEvent') GUISetIcon(@WindowsDir & '\explorer.exe') $Input[0] = GUICtrlCreateInput('', 20, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[1] = GUICtrlCreateInput('', 360, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[2] = GUICtrlCreateInput('', 20, 378, 660, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') For $i = 0 To 2 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i])) _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i]) Next $Dummy = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, '_GUIEvent') GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO') GUIRegisterMsg($WM_SIZE, 'WM_SIZE') HotKeySet('{F5}', '_TVRefresh') GUISetState() _GUICtrlTVExplorer_Expand($hTV[0], @ProgramFilesDir & '\AutoIt3') _GUICtrlTVExplorer_Expand($hTV[1]) While 1 Sleep(1000) WEnd Func _GUIEvent() Local $Path Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE GUIDelete() _GUICtrlTVExplorer_DestroyAll() Exit Case $Dummy $Path = _GUICtrlTVExplorer_GetSelected($hFocus) _GUICtrlTVExplorer_AttachFolder($hFocus) _GUICtrlTVExplorer_Expand($hFocus, $Path, 0) $hFocus = 0 EndSwitch EndFunc ;==>_GUIEvent Func _TVEvent($hWnd, $iMsg, $sPath, $hItem) Switch $iMsg Case $TV_NOTIFY_BEGINUPDATE GUISetCursor(1, 1) Case $TV_NOTIFY_ENDUPDATE GUISetCursor(2) Case $TV_NOTIFY_SELCHANGED For $i = 0 To 2 If $hTV[$i] = $hWnd Then _TVSetPath($Input[$i], $sPath) ExitLoop EndIf Next Case $TV_NOTIFY_DBLCLK ; Nothing Case $TV_NOTIFY_RCLICK ; Nothing Case $TV_NOTIFY_DELETINGITEM ; Nothing Case $TV_NOTIFY_DISKMOUNTED ; Nothing Case $TV_NOTIFY_DISKUNMOUNTED ; Nothing EndSwitch EndFunc ;==>_TVEvent Func _TVSetPath($iInput, $sPath) Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2) If GUICtrlRead($iInput) <> $Text Then GUICtrlSetData($iInput, $Text) EndIf EndFunc ;==>_TVSetPath Func _TVRefresh() Local $hWnd = _WinAPI_GetFocus() For $i = 0 To 2 If $hTV[$i] = $hWnd Then If Not $hFocus Then $hFocus = $hWnd GUICtrlSendToDummy($Dummy) EndIf Return EndIf Next HotKeySet('{F5}') Send('{F5}') HotKeySet('{F5}', '_TVRefresh') EndFunc ;==>_TVRefresh Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam) Switch $hWnd Case $hForm DllStructSetData($tMMI, 'MinTrackSize', 428, 1) DllStructSetData($tMMI, 'MinTrackSize', 450, 2) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_GETMINMAXINFO Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) Local $WC, $HC, $WT, $HT Switch $hWnd Case $hForm $WC = _WinAPI_LoWord($lParam) $HC = _WinAPI_HiWord($lParam) $WT = Floor(($WC - 60) / 2) $HT = Floor(($HC - 116) / 2) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[0]), 20, 48, $WT, $HT) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[1]), $WT + 40, 48, $WC - $WT - 60, $HT) GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[2]), 20, $HT + 96, $WC - 40, $HC - $HT - 116) GUICtrlSetPos($Input[0], 20, 20, $WT) GUICtrlSetPos($Input[1], $WT + 40, 20, $WC - $WT - 60) GUICtrlSetPos($Input[2], 20, $HT + 68, $WC - 40) For $i = 0 To 2 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i])) Next Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE
  22. 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
  23. Hi. How can I know when an item from the treeview has been checked using WM_NOTIFY function ? Items are created with _GUICtrlTreeView_Add().
  24. 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 !
  25. 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
×
×
  • Create New...