Jump to content

GUI child window back to parent with Treeview Checkbox


gfunk999
 Share

Recommended Posts

Hi All,

Could someome please tell what am I doing wrong here? ;)

Problem:

1. Click Parent Button works fine

2. Click Child Button works fine

3. Close Child Window Parent Button no longer works.

#include <GUIConstants.au3>

$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        case $button1
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd    
GUIDelete($Form1)

Func _test()
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc
Edited by gfunk999
Link to comment
Share on other sites

Hi All,

Could someome please tell what am I doing wrong here? ;)

Problem:

1. Click Parent Button works fine

2. Click Child Button works fine

3. Close Child Window Parent Button no longer works.

#include <GUIConstants.au3>

$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        case $button1
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd    
GUIDelete($Form1)

Func _test()
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc
Try this

#include <GUIConstants.au3>

$Form1 = GUICreate("Parent", 400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)
$form2 = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        Case $button1
            MsgBox(0, "Parent", "Parent")
    EndSwitch
WEnd
GUIDelete($Form1)

Func _test()
    $Form2 = GUICreate("Child", 400, 400)
    $button11 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg(1)
        Switch $nMsg[1]
            Case $Form1
                Switch $nMsg[0]
                    Case $button1
                        MsgBox(0, "Parent", "Parent")
                EndSwitch
            Case $Form2
                Switch $nMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($Form2)
                        $Form2 = 0
                        Return
                    Case $button11
                        MsgBox(0, "", "Child OK")
                EndSwitch
        EndSwitch

    WEnd

EndFunc  ;==>_test
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You have $button1 control in the child window - this is the same as $button1 in the parent.

When you create the child, $button1 is "reassigned" to the new control -> you delete the child, $button1 no longer exists.

#include <GUIConstants.au3>

$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        case $button1
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd    
GUIDelete($Form1)

Func _test()
$Form2 = GUICreate("Child", 400, 400)
$button2 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button2 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc

EDIT: nice solution martin ;)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Thanks Martin and Enaiman for the replies...

@Martin, before I read your solution I came up with this and it works. What do yo think? I made the parent into a funtion

#include <GuiConstants.au3>
#include <Process.au3>

test1()

Func test1()
$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        case $button1
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd    
GUIDelete($Form1)
EndFunc

Func _test()
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc
Link to comment
Share on other sites

Change

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc

To

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                ExitLoop
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks Martin and Enaiman for the replies...

@Martin, before I read your solution I came up with this and it works. What do yo think? I made the parent into a funtion

#include <GuiConstants.au3>
#include <Process.au3>

test1()

Func test1()
$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test()
        case $button1
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd    
GUIDelete($Form1)
EndFunc

Func _test()
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc
That's fine.

So that you can still use the button on the parent when the child window is created you need to have either a Global variable for the parent button or pass the variable to the child like this

#include <GuiConstants.au3>
#include <Process.au3>
test1()

Func test1()
$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1a = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test($button1a)
        case $button1a
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd   
GUIDelete($Form1)
EndFunc

Func _test($bp)
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1
                MsgBox(0, "", "Child OK")
        Case $bp
                MsgBox(0, "Parent", "Parent")
    EndSwitch
WEnd

EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Originally I tried adding and Exitloop after Guidelete, but that didn't work.

Change

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc

To

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                ExitLoop
        Case $button1 
                MsgBox(0, "", "Child OK")
    EndSwitch
WEnd

EndFunc
Edited by gfunk999
Link to comment
Share on other sites

Thanks again Martin

That's fine.

So that you can still use the button on the parent when the child window is created you need to have either a Global variable for the parent button or pass the variable to the child like this

#include <GuiConstants.au3>
#include <Process.au3>
test1()

Func test1()
$Form1 = GUICreate("Parent",400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1a = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            _test($button1a)
        case $button1a
            MsgBox(0, "Parent", "Parent")
        EndSwitch
WEnd   
GUIDelete($Form1)
EndFunc

Func _test($bp)
$Form2 = GUICreate("Child", 400, 400)
$button1 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)

GUISetState(@SW_SHOW)

While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Return
        Case $button1
                MsgBox(0, "", "Child OK")
        Case $bp
                MsgBox(0, "Parent", "Parent")
    EndSwitch
WEnd

EndFunc
Link to comment
Share on other sites

This seems to make more sense to me -

#include <GUIConstants.au3>

Global $Form2 = 0, $button11 = -1

$Form1 = GUICreate("Parent", 400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $Form1
                    Exit
                Case $Form2
                    GUIDelete($Form2)
                    $Form2 = 0
            EndSwitch
        Case $button
            If $Form2 = 0 Then _test()
        Case $button1
            MsgBox(0, "Parent", "Parent OK")
        Case $button11
            MsgBox(0, "", "Child OK")
    EndSwitch
WEnd
GUIDelete($Form1)

Func _test()
    $Form2 = GUICreate("Child", 400, 400)
    $button11 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)
    GUISetState(@SW_SHOW)
EndFunc ;==>_test
Link to comment
Share on other sites

Is $Form2 = 0 substituting return?

This seems to make more sense to me -

#include <GUIConstants.au3>

Global $Form2 = 0, $button11 = -1

$Form1 = GUICreate("Parent", 400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("Parent", 10, 200, 100, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $Form1
                    Exit
                Case $Form2
                    GUIDelete($Form2)
                    $Form2 = 0
            EndSwitch
        Case $button
            If $Form2 = 0 Then _test()
        Case $button1
            MsgBox(0, "Parent", "Parent OK")
        Case $button11
            MsgBox(0, "", "Child OK")
    EndSwitch
WEnd
GUIDelete($Form1)

Func _test()
    $Form2 = GUICreate("Child", 400, 400)
    $button11 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)
    GUISetState(@SW_SHOW)
EndFunc;==>_test
Link to comment
Share on other sites

Sorry to bug again, based on wraithdu example I added more code, but the problem now I can't get the Status font colors to change while going through the loop. Check out the code everything needed is inlcuded for testing. thanks again All

#include <file.au3>
#include <array.au3>
#include <GuiTreeView.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>

Global $Form2 = 0, $button11 = -1
Dim $array, $count, $h_tree, $a, $b

FileDelete(@TempDir & "\a.txt")
FileDelete(@TempDir & "\b.txt")
FileDelete(@TempDir & "\main.txt")
DirCreate(@TempDir & "\txt")
FileWrite(@TempDir & "\txt\a.txt", "")
FileWrite(@TempDir & "\txt\b.txt", "")
Filewrite(@TempDir & "\main.txt", "a.txt" & @CRLF & "b.txt")
    $main = FileOpen(@TempDir & "\main.txt", 0)
    $main = FileRead($main)

$status = ""
$status2 = "Found File Success!"
$status3 = "File A must exist! Use Child Window to select File A"
$status4 = "File B must exist! Use Child Window to select File B"

$Form1 = GUICreate("Parent", 400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("OK", 10, 200, 100, 30)
$label1 = GUICtrlCreateLabel("Status:", 10, 25, 93, 20)
                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$label2 = GUICtrlCreateLabel($status, 70, 25, 400, 50)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $Form1
                    Exit
                Case $Form2
                    GUIDelete($Form2)
                    $Form2 = 0
            EndSwitch
        Case $button
            If $Form2 = 0 Then _test()
        Case $button1
            _a()
        Case $button11
            _fileselect()           
    EndSwitch
WEnd
GUIDelete($Form1)

Func _test()
    $Form2 = GUICreate("Child", 400, 400)
    $treeview = GUICtrlCreateTreeView(10, 70, 75, 75, $TVS_CHECKBOXES)
    $h_tree = ControlGetHandle($Form2, "", $treeview)
    
    $button11 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)
    
    GUISetState(@SW_SHOW)
    $find = FileFindFirstFile(@TempDir & "\txt\*.*")
    
    While 1
    $nxtfile = FileFindNextFile($find)
        If @error Then ExitLoop
            GUICtrlCreateTreeViewitem($nxtfile,$treeview)
                $count = ControlTreeView($Form2, "", $h_tree, "GetItemCount")
    WEnd
EndFunc;==>_test

Func _fileselect()
        For $item = 0 To $count
            $item1 = "#" & $item
            $ischk = ControlTreeView ($Form2, "", $h_tree, "IsChecked", $item1 )
                If $ischk = 1 Then
                    $gettext = ControlTreeView($Form2, "", $h_tree, "GetText", $item1)
                        $stringret = StringInStr($main, $gettext)
                            If Not $stringret = 0 Then
                                FileWrite(@TempDir & "\" & $gettext, "")
                            EndIf                           
                EndIf        
        Next
            If FileExists(@TempDir & "\a.txt") Then
                $a = 1
            EndIf
            If FileExists(@TempDir & "\b.txt") Then
                $b = 1
            EndIf
            If $a = 1 OR $b = 1 Then
                    GUIDelete($Form2)
                    $Form2 = 0      
            Else
                MsgBox(0, "", "I returned")
                Return
            EndIf

EndFunc

;=======================================================
;A
;=======================================================

Func _a()
    If not _FileReadToArray(@TempDir & "\a.txt", $array) Then
        GUICtrlSetData($label2, $status3)
        _redfont()
        Return
    Else
        _aa()
    EndIf
EndFunc 

Func _aa()
        GUICtrlSetData($label2, $status2 & " A")
        _greenfont()
        Sleep(5000)
        _b()
EndFunc

;=======================================================
;B
;=======================================================

Func _b()
    If not _FileReadToArray(@TempDir & "\b.txt", $array) Then
        GUICtrlSetData($label2, $status4)
        _redfont()
        Return
    Else
        GUICtrlSetData($label2, $status2 & " B")
        _greenfont()
        Sleep(5000)
        _c()
    EndIf
EndFunc
    
;=======================================================
;C
;=======================================================

Func _c()   
        MsgBox(0, "F", "I'm in Func C")
            Exit
EndFunc 

;=======================================================
;Fonts
;=======================================================

Func _redfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor(-1, 0xFF0000)
EndFunc
    
Func _greenfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor(-1, 0x008000)
EndFunc

Nope, it's a flag so that only one child window can be created at a time. See 'Case $button'.

Edited by gfunk999
Link to comment
Share on other sites

Don't do this in your functions

Func _redfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif");<------------
            GUICtrlSetColor(-1, 0xFF0000)
EndFunc
   
Func _greenfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif");<-----------------
            GUICtrlSetColor(-1, 0x008000)
EndFunc

The -1 means use the last control created. You don't know what that will be when the functions are called so you must use the correct variable ($label2).

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

:) oh...that easy, FOR YOU eh...lol thanks Martin, just when I thought I was getting the hang of it I goofed up.

Don't do this in your functions

Func _redfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif");<------------
            GUICtrlSetColor(-1, 0xFF0000)
EndFunc
   
Func _greenfont()
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif");<-----------------
            GUICtrlSetColor(-1, 0x008000)
EndFunc

The -1 means use the last control created. You don't know what that will be when the functions are called so you must use the correct variable ($label2).

Link to comment
Share on other sites

Newly applied changes from Martin, just in case for those who don't know what's going on. Again, thanks to everyone who replied. Awsome forum!

#include <file.au3>
#include <array.au3>
#include <GuiTreeView.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>

Global $Form2 = 0, $button11 = -1
Dim $array, $count, $h_tree, $a, $b

FileDelete(@TempDir & "\a.txt")
FileDelete(@TempDir & "\b.txt")
FileDelete(@TempDir & "\main.txt")
DirCreate(@TempDir & "\txt")
FileWrite(@TempDir & "\txt\a.txt", "")
FileWrite(@TempDir & "\txt\b.txt", "")
Filewrite(@TempDir & "\main.txt", "a.txt" & @CRLF & "b.txt")
    $main = FileOpen(@TempDir & "\main.txt", 0)
    $main = FileRead($main)

$status = ""
$status2 = "Found File Success!"
$status3 = "File A must exist! Use Child Window to select File A"
$status4 = "File B must exist! Use Child Window to select File B"

$Form1 = GUICreate("Parent", 400, 300, 264, 239)
$button = GUICtrlCreateButton("Child", 10, 100, 100, 30)
$button1 = GUICtrlCreateButton("OK", 10, 200, 100, 30)
$label1 = GUICtrlCreateLabel("Status:", 10, 25, 93, 20)
                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$label2 = GUICtrlCreateLabel($status, 70, 25, 400, 50)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $Form1
                    Exit
                Case $Form2
                    GUIDelete($Form2)
                    $Form2 = 0
            EndSwitch
        Case $button
            If $Form2 = 0 Then _test()
        Case $button1
            _a()
        Case $button11
            _fileselect()         
    EndSwitch
WEnd
GUIDelete($Form1)

Func _test()
    $Form2 = GUICreate("Child", 400, 400)
    $treeview = GUICtrlCreateTreeView(10, 70, 75, 75, $TVS_CHECKBOXES)
    $h_tree = ControlGetHandle($Form2, "", $treeview)
    
    $button11 = GUICtrlCreateButton(" Child OK", 10, 360, 140, 20)
    
    GUISetState(@SW_SHOW)
    $find = FileFindFirstFile(@TempDir & "\txt\*.*")
    
    While 1
    $nxtfile = FileFindNextFile($find)
        If @error Then ExitLoop
            GUICtrlCreateTreeViewitem($nxtfile,$treeview)
                $count = ControlTreeView($Form2, "", $h_tree, "GetItemCount")
    WEnd
EndFunc;==>_test

Func _fileselect()
        For $item = 0 To $count
            $item1 = "#" & $item
            $ischk = ControlTreeView ($Form2, "", $h_tree, "IsChecked", $item1 )
                If $ischk = 1 Then
                    $gettext = ControlTreeView($Form2, "", $h_tree, "GetText", $item1)
                        $stringret = StringInStr($main, $gettext)
                            If Not $stringret = 0 Then
                                FileWrite(@TempDir & "\" & $gettext, "")
                            EndIf                     
                EndIf       
        Next
            If FileExists(@TempDir & "\a.txt") Then
                $a = 1
            EndIf
            If FileExists(@TempDir & "\b.txt") Then
                $b = 1
            EndIf
            If $a = 1 OR $b = 1 Then
                    GUIDelete($Form2)
                    $Form2 = 0    
            Else
                MsgBox(0, "", "I returned")
                Return
            EndIf

EndFunc

;=======================================================
;A
;=======================================================

Func _a()
    If not _FileReadToArray(@TempDir & "\a.txt", $array) Then
        GUICtrlSetData($label2, $status3)
        _redfont()
        Return
    Else
        _aa()
    EndIf
EndFunc 

Func _aa()
        GUICtrlSetData($label2, $status2 & " A")
        _greenfont()
        Sleep(5000)
        _b()
EndFunc

;=======================================================
;B
;=======================================================

Func _b()
    If not _FileReadToArray(@TempDir & "\b.txt", $array) Then
        GUICtrlSetData($label2, $status4)
        _redfont()
        Return
    Else
        GUICtrlSetData($label2, $status2 & " B")
        _greenfont()
        Sleep(5000)
        _c()
    EndIf
EndFunc
    
;=======================================================
;C
;=======================================================

Func _c()   
        MsgBox(0, "F", "I'm in Func C")
            Exit
EndFunc 

;=======================================================
;Fonts
;=======================================================

Func _redfont()
            GUICtrlSetFont($label2, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($label2, 0xFF0000)
EndFunc
    
Func _greenfont()
            GUICtrlSetFont($label2, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($label2, 0x008000)
EndFunc
Edited by gfunk999
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...