Jump to content
Sign in to follow this  
johnmcloud

[SOLVED] Dynamic GUI Creation

Recommended Posts

johnmcloud

Hi guys,

I'm try to create a gui can be create element by itself. This is what i have done:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIResizeMode", BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE))

Global Const $Element_For_Column = 5 ; Max number of element for column
Global Const $Max_Element = 15 ; Number of total element
Global $iCount = 1 ; Number 1 is used for basic element
Global $Move_Top, $Move_Left, $Temp_iCount
Global $Input_[1][1], $Label_[1][1], $Button_[1][2]

$hGUI = GUICreate("Dynamic GUI", 233, 107, -1, -1)
$Label_A1 = GUICtrlCreateLabel("This is a label n°1", 8, 26, 90, 17)
$Input_A1 = GUICtrlCreateInput("", 8, 43, 161, 21)
$Button_A1 = GUICtrlCreateButton("1", 176, 41, 51, 25)
$Button_A2 = GUICtrlCreateButton("Check Input", 8, 72, 75, 25)
$Button_Minus = GUICtrlCreateButton("-", 176, 2, 19, 25)
$Button_Plus = GUICtrlCreateButton("+", 210, 2, 19, 25)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_A1
GUICtrlSetData($Input_A1, "You have clicked button 1")
Case $Button_A2
_Test_Func($Input_A1)
Case $Button_Plus
_Add_Element()
Case $Button_Minus
Delete_Element()
Case Else
For $i = 0 To UBound($Button_, 1) - 1
    Switch $msg
     Case $Button_[$i][0]
     GUICtrlSetData($Input_[$i][0], "You have clicked button " & $i + 1)
     Case $Button_[$i][1]
     _Test_Func($Input_[$i][0])
    EndSwitch
Next
EndSwitch
WEnd

Func _Test_Func($Value)
MsgBox(0, 0, "This is the value of Input: " & GUICtrlRead($Value) & @CRLF)
EndFunc ;==>_Test_Func

Func _Add_Element()
Global $hGUISize_Height = 89, $hGUISize_Width = 250
Local Const $Size = WinGetPos($hGUI)
$Temp_iCount += 1
$iCount += 1
$Move_Top += 90
If $Temp_iCount = $Element_For_Column Then
If $iCount <= $Max_Element Then
WinMove($hGUI, "", Default, Default, $Size[2] + $hGUISize_Width, Default)
_Middle($hGUI, "")
$Move_Top = 0 ; reset top
$Move_Left += 250 ; create left vaule
$Temp_iCount = 0 ; reset temp_element
EndIf
EndIf
If $iCount <= $Max_Element Then
ReDim $Label_[$iCount][$iCount]
ReDim $Input_[$iCount][$iCount]
ReDim $Button_[$iCount][$iCount * 2]
If $iCount <= $Element_For_Column Then
$Label_[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8, 26 + $Move_Top, 90, 17)
$Input_[$iCount - 1][0] = GUICtrlCreateInput("", 8, 43 + $Move_Top, 161, 21)
$Button_[$iCount - 1][0] = GUICtrlCreateButton($iCount, 176, 41 + $Move_Top, 51, 25)
$Button_[$iCount - 1][1] = GUICtrlCreateButton("Check Input", 8, 72 + $Move_Top, 75, 25)
WinMove($hGUI, "", Default, Default, Default, $Size[3] + $hGUISize_Height)
_Middle($hGUI, "")
Else
$Label_[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8 + $Move_Left, 26 + $Move_Top, 90, 17)
$Input_[$iCount - 1][0] = GUICtrlCreateInput("", 8 + $Move_Left, 43 + $Move_Top, 161, 21)
$Button_[$iCount - 1][0] = GUICtrlCreateButton($iCount, 176 + $Move_Left, 41 + $Move_Top, 51, 25)
$Button_[$iCount - 1][1] = GUICtrlCreateButton("Check Input", 8 + $Move_Left, 72 + $Move_Top, 75, 25)
EndIf
EndIf
If $iCount > $Max_Element Then
$iCount = $Max_Element
$Temp_iCount = $Element_For_Column - 1
EndIf
EndFunc ;==>_Add_Element

Func Delete_Element()
Local Const $Size = WinGetPos($hGUI)
Local $Temp_Move_Top = 90 ; Equal to $Move_Top
If $iCount = 1 Then ; No element
$iCount = 1
Return
Else
GUICtrlDelete($Label_[$iCount - 1][0]) ; delete element
GUICtrlDelete($Input_[$iCount - 1][0]) ; delete element
GUICtrlDelete($Button_[$iCount - 1][0]) ; delete element
GUICtrlDelete($Button_[$iCount - 1][1]) ; delete element
EndIf
If $iCount <> 0 Then
If $iCount <= $Element_For_Column Then
WinMove($hGUI, "", Default, Default, Default, $Size[3] - $hGUISize_Height) ; resize gui
_Middle($hGUI, "")
EndIf
EndIf
If $Temp_iCount = 0 Then ; New Column
WinMove($hGUI, "", Default, Default, $Size[2] - $hGUISize_Width, Default) ; resize gui
_Middle($hGUI, "")
$Move_Left -= 250 ; Remove left value
$Temp_iCount += $Element_For_Column ; Remove new colum
EndIf
$iCount -= 1 ; Delete one count
$Temp_iCount -= 1; Delete one temp count
If $Move_Top = 0 Then ; Equal to start posizion
$Move_Top = $Temp_Move_Top * ($Element_For_Column - 1)
Else
$Move_Top -= 90 ; Delete one position
EndIf
EndFunc ;==>Delete_Element

Func _Middle(Const $win, Const $txt) ; Snippet Valuater - cdkid
Local Const $Size = WinGetClientSize($win, $txt)
Local Const $y = (@DesktopHeight / 2) - ($Size[1] / 2)
Local Const $x = (@DesktopWidth / 2) - ($Size[0] / 2)
Return WinMove($win, $txt, $x, $y)
EndFunc ;==>_Middle

1) The gui can create element but the size of the width is good only for the second element, then increase every 3°, 4° etc.

2) Buttons don't work because i don't know how to set in the While...WEnd and the realtive function

3) I don't know how to make the creation of 3 element for column until the $Max_Element is reached

4) I don't know how to delete group element ( except the first )

Thanks ;)

EDIT: No more to go, if someone has suggestion/improvement just ask ;)

Edited by johnmcloud

Share this post


Link to post
Share on other sites
jaberwacky

Try this and see if it aint what you want.

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

Opt("GUIResizeMode",  BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE))

Global Const $Element_For_Column = 3 ; Max number of element for column

Global Const $Max_Element = 9 ; Number of total element

Global $iCount = 1 ; Number 1 is used for basic element

Global $Move_Top

Global $Move_Left

Global $Temp_iCount

Global Const $hGUI = GUICreate("Dynamic GUI", 233, 107, -1, -1)

Global Const $Label_A1 = GUICtrlCreateLabel("This is a label n°1", 8, 26, 90, 17)

Global Const $Input_A1 = GUICtrlCreateInput("", 8, 43, 161, 21)

Global Const $Button_A1 = GUICtrlCreateButton("1", 176, 41, 51, 25)

Global Const $Button_A2 = GUICtrlCreateButton("Check Input", 8, 72, 75, 25)

Global Const $Button_Minus = GUICtrlCreateButton("-", 176, 2, 19, 25)

Global Const $Button_Plus = GUICtrlCreateButton("+", 210, 2, 19, 25)

Global $ctrl_array[1][4]

GUISetState(@SW_SHOWNORMAL)

Global $msg = ''

Do
    $msg = GUIGetMsg()

    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button_A1
            GUICtrlSetData($Input_A1, "You have clicked button 1")

        Case $Button_A2
            _Test_Func($Input_A1)

        Case $Button_Plus
            _Add_Element()

        Case $Button_Minus
            Delete_Element()

        Case Else
            Global $ctrl_array_upbound = UBound($ctrl_array, 1)

            For $i = 0 To $ctrl_array_upbound - 1
                Switch $msg
                    Case $ctrl_array[$i][2]
                        GUICtrlSetData($ctrl_array[$i][1], "You have clicked button " & $i + 1)

                    Case $ctrl_array[$i][3]
                        _Test_Func($ctrl_array[$i][1])
                EndSwitch
            Next
    EndSwitch
Until False

Func _Test_Func(Const $Value)
    ConsoleWrite("This is the value of Input: " & GUICtrlRead($Value) & @crlf)
EndFunc   ;==>_Test_Func

Func _Add_Element()
    Local Const $Size = WinGetClientSize($hGUI, '')

    $Temp_iCount += 1

    $iCount += 1

    $Move_Top += 90

    If $Temp_iCount = $Element_For_Column Then
        If $iCount <= $Max_Element Then
            Local Const $hGUISize_Width = 250

            WinMove($hGUI, "", Default, Default, $Size[0] + $hGUISize_Width, Default)

            _Middle($hGUI, "")

            $Move_Top = "" ; reset top

            $Move_Left += 240 ; create left vaule

            $Temp_iCount = "" ; reset temp_element
        EndIf
    EndIf

    If $iCount <= $Max_Element Then
        ReDim $ctrl_array[$iCount][$iCount * 4]

        If $iCount <= $Element_For_Column Then
            $ctrl_array[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8, 26 + $Move_Top, 90, 17) ; how to set the variable name?

            $ctrl_array[$iCount - 1][1] = GUICtrlCreateInput("", 8, 43 + $Move_Top, 161, 21)

            $ctrl_array[$iCount - 1][2] = GUICtrlCreateButton($iCount, 176, 41 + $Move_Top, 51, 25)

            $ctrl_array[$iCount - 1][3] = GUICtrlCreateButton("Check Input", 8, 72 + $Move_Top, 75, 25)

            Local Const $hGUISize_Height = 120

            WinMove($hGUI, "", Default, Default, Default, $Size[1] + $hGUISize_Height)

            _Middle($hGUI, "")
        Else
            $ctrl_array[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8 + $Move_Left, 26 + $Move_Top, 90, 17) ; how to set the varable name?

            $ctrl_array[$iCount - 1][1] = GUICtrlCreateInput("", 8 + $Move_Left, 43 + $Move_Top, 161, 21)

            $ctrl_array[$iCount - 1][2] = GUICtrlCreateButton($iCount, 176 + $Move_Left, 41 + $Move_Top, 51, 25)

            $ctrl_array[$iCount - 1][3] = GUICtrlCreateButton("Check Input", 8 + $Move_Left, 72 + $Move_Top, 75, 25)
        EndIf
    EndIf
EndFunc   ;==>_Add_Element

Func Delete_Element()
    ;???
EndFunc   ;==>Delete_Element

Func _Middle(Const $win, Const $txt) ; Snippet Valuater - cdkid
    Local Const $Size = WinGetClientSize($win, $txt)

    Local Const $y = (@DesktopHeight / 2) - ($Size[1] / 2)

    Local Const $x = (@DesktopWidth / 2) - ($Size[0] / 2)

    Return WinMove($win, $txt, $x, $y)
EndFunc   ;==>_Middle

I'll leave deleting them as an exercise for you. =)

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites
johnmcloud

Thanks, i have make some little change ( i have make 4 different array for every element ) and i have added the deleting func...but it's a little bugged :D

The script is on the first post. Can you/someone check it out?

Thanks

Share this post


Link to post
Share on other sites
johnmcloud

I have resolved the 99% of the problems with Delete_Element() ( i have updated the script on the first post ) i have only the last

When i created 6 element ( with 5 = Max element for column, so it created a new column with 1 element ) and i try to delete the 6° and recreate it, work fine and no problems

When i created 6 element ( with 5 = Max element for column, so it created a new column with 1 element ) and i try to delete the 6° and the 5° ( the result is only one column with four element ) and recreate the 5° again, i don't see anything

Tips?

EDIT: I have resolve the last problem, seems work fine now. Waiting for expert if the have improvement-suggestion on this script. Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites
johnmcloud

Silence gives consent ( i hope )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


    • WilliamasKumeliukas
      By WilliamasKumeliukas
      Hello everyones reading this post,
      I'm struggling at resizing properly my radio buttons to fit long text inside without affecting others radio buttons and also adjust position of them relative to the string.
      I tried with _StringSize UDF but I guess im too tired to figure out how to use it correctly..
      I also tried: _Control_SetWidth2Text I found on this forum, it work aslong im not maximizing GUI (radio text is gone when I maximize and maximize is a must)
       
      here is the code example, I hope someone can figure out (sorry if guictrlsetpos is not included in the example, I know thats probably the way to go but I wanted to make sure there is nothing better before use it)
      Thank you
       
      Br,
      ~WilliamasKumeliukas
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Array.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <EditConstants.au3> #include <GUIListBox.au3> #include <ButtonConstants.au3> #include <ProgressConstants.au3> #include <ColorConstants.au3> #include <AutoitConstants.au3> #include <Misc.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #Region Opt's Opt("GUIResizeMode", 802) #EndRegion Opt's Global $q = "INTRO LINE" & @CRLF & @CRLF & "description of everything until user press start." Global $file = @TempDir & "\test.p" destroy() Global $msg, $score = 0, $rate, $com, $total = 0, $cfile, $cq, $i = 0, $time = 0, $min = 0, $sec = 0, $hour = 0, $qf, $ii = 0 Main() Func Main() Global $iGUIInitSize = 550 #Region GUI Opt("GUICloseOnEsc", 1) Global $gui = GUICreate("example", 1124, 550,-1 ,-1, BitOR($WS_MAXIMIZEBOX , $WS_MINIMIZEBOX)) Global $gui_size = WinGetClientSize($gui) Global $iFontSize = Int(2 * (.25 + (8 * $gui_size[0] / $iGUIInitSize))) / 2 Global $options = GUICtrlCreateMenu("&Options") Global $guide = GUICtrlCreateMenuItem("Guide", $options) Global $restart = GUICtrlCreateMenuItem("Restart", $options) Global $about = GUICtrlCreateMenuItem("About", $options) Global $exit = GUICtrlCreateMenuItem("Exit", $options) Global $extra = GUICtrlCreateMenu("Extras") Global $creator = GUICtrlCreateMenu("CQB", $extra ) Global $new = GUICtrlCreateMenuItem("custom QP", $creator) Global $load = GUICtrlCreateMenuItem("CQ", $creator ) Global $timer = GUICtrlCreateLabel("", 752, 472, 294, 30, $WS_BORDER) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetFont(-1, $iFontSize) GUICtrlSetState($timer, $GUI_HIDE) Global $info = GUICtrlCreateLabel( $q, 200, 20, 700, 200, $SS_CENTER ) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) $fi = GUICtrlSetFont($info, $iFontSize) Global $a = GUICtrlCreateRadio("A)", 100, 210, $WS_EX_CLIENTEDGE) $fa = GUICtrlSetFont($a, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($a, 16) Global $b = GUICtrlCreateRadio("B)", 100, 310 , $WS_EX_CLIENTEDGE) $fb = GUICtrlSetFont($b, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($b, 16) Global $c = GUICtrlCreateRadio("C)", 750, 210 , $WS_EX_CLIENTEDGE) $fc = GUICtrlSetFont($c, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($c, 16) Global $d = GUICtrlCreateRadio( "D) ", 750, 310, $WS_EX_CLIENTEDGE) $fd = GUICtrlSetFont($d, 15) GUICtrlSetResizing (-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($d, 16) Global $sign = GUICtrlCreateLabel( $file, 420, 480, -1, -1, BitOR ( $SS_CENTER, $WS_BORDER ) ) GUICtrlSetResizing ( -1, BitOR ( $GUI_DOCKHCENTER, $GUI_DOCKVCENTER ) ) GUICtrlSetFont($sign, 12) Global $yb = GUICtrlCreateRadio("True", 200, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER,$GUI_DOCKSIZE)) GUICtrlSetFont($yb, 15) GUICtrlSetState($yb, 32) Global $nb = GUICtrlCreateRadio("False", 700, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER, $GUI_DOCKSIZE)) GUICtrlSetFont($nb, 15) GUICtrlSetState($nb, 32) Global $start = GUICtrlCreateButton("Start", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($start, 12) Global $valid = GUICtrlCreateButton("Confirm", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($valid, 12) GUICtrlSetState($valid, 32) GUISetState(@SW_SHOW) #EndRegion GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Switch MsgBox(4096 + 4, "Warning", "Are you sure to exit?") Case 6 AdlibUnRegister("timer") If Not $qf = "" Then FileClose($file) EndIf Exit Case 7 ContinueLoop EndSwitch Case $start ;AdlibRegister("timer") ;Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0) ;qloop($file) GUICtrlSetData($a, "A) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($b, "B) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($c, "C) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($d, "D) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") Case $restart MsgBox(4096, "Warning", 'Normally, your suposed to start something before restarting it.') ContinueLoop Case $new ;GUISetState(@SW_HIDE, $gui) ;_CustomNew() ContinueLoop Case $load ;_CustomLoad() Case $about ;_About() EndSwitch WEnd EndFunc ;Main() Func timer() If $time = 0 Then Global $time = TimerInit() Global $diff = TimerDiff($time) Global $sec = Int(Mod($diff / 1000, 60)) Global $min = Int(Mod($diff / 60000, 60)) Global $hour = Int($diff / 3600000) If $sec < 10 Then $sec = "0" & $sec If $min < 10 Then $min = "0" & $min If $hour < 10 Then $hour = "0" & $hour GUICtrlSetData($timer, "Temps: " & $hour & ":" & $min & ":" & $sec) EndFunc ;==>timer Func destroy() If FileExists($file) Then FileDelete($file) EndIf DirCreate(@TempDir & "\About") FileInstall("C:\test.txt", $file) EndFunc ;==>destroy  
    • xtcislove
      By xtcislove
      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:

       
       
×