Sign in to follow this  
Followers 0
Ace08

GUI Problems

9 posts in this topic

hi guys im still having troubles with GUI.... how can i close a child GUI? also, would a declared value in a child can be used by a parent or the other way around?


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites



Ace08,

To learn how to use multiple GUIs and only close the one you want, look at the Managing Multiple GUIs tutorial in the Wiki. ;)

Variables in a script are available throughout it - if you use the correct scope. Look at the Variables - using Global, Local and ByRef tutorial in the same place. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

thanks a lot Melba23 will look into it now ;)


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

@Melba23

Thanks i was able to solve the closing issue but im still stuck with the variables from a child that can be used by a parent....

here is what i did

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $Saverate
Main()

Func Main()
    local $Upload, $Rate, $var, $Edit, $Report, $Generate, $MainF
    $MainF = GUICreate("Al Raji", 520 ,100);Creates The GUI

    Opt("GUICoordMode", 2)
    $Upload = GUICtrlCreateButton("Upload", 10, 30, 100)
    $Rate = GUICtrlCreateButton("Rate", 0, -1)
    $Edit = GUICtrlCreateButton("Edit", 0, -1)
    Dim $AccelKeys[2][2]=[["^U", $Upload], ["^n", $Rate]]
    GUISetAccelerators($AccelKeys)
    GUISetState() 
    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Upload
               $var = FileOpenDialog ("Choose The File to be Converted.", "C:\Autoit\Script", "TransactionFile(*.*)" , 2)
                If @error Then
                Else
                    $file = FileOpen($var, 0)
                    If $file = -1 Then
                        MsgBox(0, "Error", "Unable to open file.")
                        Exit
                    EndIf
                endif
            Case $Rate
                ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                Ratein()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
            Case $Edit
                msgbox(0,"",$Saverate)
        EndSwitch
    WEnd
EndFunc

Func Ratein()
    local $RateForm,$WS_POPUPWINDOW, $Ratein,$Generate
    $RateForm = GUICreate("Input Rate", 180 ,80,-1,-1,$WS_POPUPWINDOW);Creates The GUI
    $Ratein = GUICtrlCreateInput("", 10, 5, 80, 20)
    $Generate = GUICtrlCreateButton("Generate", 0, -1, 80)
    GUISetState() 
    ; Run the GUI until the dialog is closed
    While 1
          Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($RateForm)
                ExitLoop
            case $Generate
                $Saverate = $Ratein
                GUIDelete($RateForm)
                ExitLoop
        EndSwitch
    WEnd
endFunc

but i get a value of 8 regardless of what i put inside the inputbox


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

Ace08,

That is because you are working with the ControlID of the input and not its content. :)

Change this line:

$Saverate = $Ratein

to read

$Saverate = GUICtrlRead($Ratein)

and you should find it works. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks again Melba23 but i didn't get it i'll go look at GUICtrlRead and see thanks again ;)


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

Ace08,

i didn't get it

When you create a control, AutoIt assigns it a ControlID so you can address the control elsewhere in your script. This ControlID is the number returned by the GUICtrlCreate* command - in your case above $Ratein is set to the ControlID of the input:

$Ratein = GUICtrlCreateInput("", 10, 5, 80, 20)

These ControlIDs are stored in an internal AutoIt array (the number is actually the index of the entry) - your input is control 8 in this script.

If you use

$Saverate = $Ratein

then you are just setting $Saverate to the value of the ControlID.

By using

$Saverate = GUICtrlRead($Ratein)

you are setting it to the content of the control.

All clear now? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

ohh i see thanks again Melba23 ;)

i'm learning this little by little :)


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

uhm guys how can i change the value of an already declared label in a GUI?

what i did was create a gui with a label and a button that when pressed will then create another gui that has an inputbox and a button after clicking the button the child gui will then close.

here is the code

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $NewVal = 0
Main()
Func Main()
     local $Upload, $Rate, $var, $Change,$MainF
    $MainF = GUICreate("GUI", 220 ,100);Creates The GUI
    Opt("GUICoordMode", 2)
    $Change = GUICtrlCreateButton("Update", 10, 30, 100)
    GUICtrlCreateLabel("Current Rate is " & $NewVal, -100, 2)
    GUISetState() 
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Change
                 ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                Ch()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
        EndSwitch
    WEnd
EndFunc

Func Ch()
local $InpForm,$WS_POPUPWINDOW, $Inp,$Generate
    $InpForm = GUICreate("Input Rate", 180 ,80,-1,-1,$WS_POPUPWINDOW);Creates The GUI
    $Inp = GUICtrlCreateInput("", 10, 5, 80, 20)
    $Generate = GUICtrlCreateButton("Generate", 0, -1, 80)
    Dim $AccelKeys[2][2]=[["{ENTER}", $Generate], ["{ESC}", $Generate]]
    GUISetAccelerators($AccelKeys)
    GUISetState() 
    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($InpForm)
                ExitLoop
            case $Generate
                $NewVal = GUICtrlRead($Inp)
                GUIDelete($InpForm)
                WinActivate("GUI", "")
                ExitLoop
        EndSwitch
    WEnd
endFunc

i got this one apparently it was the same problem ;)

just needed to add ctrlsetdata and it went well :)

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

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  
Followers 0