Jump to content

calling GUi's in other func's


 Share

Recommended Posts

ok im playing around a little in Autoit and i thought i would try and make a simple gui that will hold numerous links to variouse files ect

the idea is that uppon hitting + button at the top it opens another gui (inanother func) for you to sort out the links ect ect,

all is going well until i choose to close the second gui.

if i hit close or the X at top right it closes the gui but doesnt exit the func(i think) making it unable to use the + button on the origional gui again. i dont know maybe someone can help me.

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


$DesctopWidth = @DesktopWidth
$LeftPlace = $DesctopWidth - 150

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 150, 300, $LeftPlace,0)
$Add = GUICtrlCreateButton("+", 0, 0, 19, 17, $WS_GROUP)
$Minus = GUICtrlCreateButton("-", 19, 0, 19, 17, $WS_GROUP)
$BTMenuClose = GUICtrlCreateButton("X", 130, 0, 19, 17, $WS_GROUP)
$BTMenuAbout = GUICtrlCreateButton("?", 110, 0, 19, 17, $WS_GROUP)
$Button3 = GUICtrlCreateButton("%", 38, 0, 19, 17, $WS_GROUP)
$Graphic1 = GUICtrlCreateGraphic(0, 18, 151, 2)
GUICtrlSetColor(-1, 0x000000)
GUICtrlCreateGraphic(10, 40, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 62, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 84, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 106, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 128, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 150, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 172, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 194, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 216, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 238, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 260, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlCreateGraphic(10, 282, 130, 2)
GUICtrlSetColor(-1, 0x0000FF)

$LinksBT1 = GUICtrlCreateLabel("", 8, 22,-1,18)
$LinksBT2 = GUICtrlCreateLabel("", 8, 44,-1,18)
$LinksBT3 = GUICtrlCreateLabel("", 8, 66,-1,18)
$LinksBT4 = GUICtrlCreateLabel("", 8, 88,-1,18)
$LinksBT5 = GUICtrlCreateLabel("", 8, 110,-1,18)
$LinksBT6 = GUICtrlCreateLabel("", 8, 132,-1,18)
$LinksBT7 = GUICtrlCreateLabel("", 8, 154,-1,18)
$LinksBT8 = GUICtrlCreateLabel("", 8, 176,-1,18)
$LinksBT9 = GUICtrlCreateLabel("", 8, 198,-1,18)
$LinksBT10 = GUICtrlCreateLabel("", 8, 220,-1,18)
$LinksBT11 = GUICtrlCreateLabel("", 8, 242,-1,18)
$LinksBT12 = GUICtrlCreateLabel("", 8, 264,-1,18)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $BTMenuClose
            Exit
        Case $BTMenuAbout
            MsgBox(0,"ABout","About section")
        Case $Add
            Add()

    EndSwitch
WEnd

Func Add()
    #Region ### START Koda GUI section ### Form=
$AddGUI = GUICreate("Form1", 262, 124, 379, 151)
$LableA1 = GUICtrlCreateLabel("Add A link to your Dock", 8, 8, 116, 17)
$GRAB = GUICtrlCreateButton("Get File", 168, 32, 75, 25, $WS_GROUP)
$Linkpath = GUICtrlCreateInput("File Location", 8, 34, 153, 21)
$Linkname = GUICtrlCreateInput("Link Name, 30Chars Max", 32, 64, 129, 21)
$ADD = GUICtrlCreateButton("ADD", 64, 88, 75, 25, $WS_GROUP)
$CLOSE = GUICtrlCreateButton("CLOSE", 144, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $ADDMsg = GUIGetMsg()
    Switch $ADDMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($AddGUI)
            ExitLoop
        Case $CLOSE
            GUIDelete($AddGUI)
            ExitLoop
        Case $ADD
            ;DO SOME STUFF

        Case $GRAB
            $Name = FileOpenDialog("File Link",@DesktopDir, "all (*.*)")
            GUICtrlSetData($Linkpath, $Name)

    EndSwitch
WEnd
EndFunc

Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D

Link to comment
Share on other sites

  • Moderators

Thornhunt,

If I told you that AutoIt capitialises all variables when it runs, would these lines give you a clue? ;)

; From $Form1
$Add = GUICtrlCreateButton("+", 0, 0, 19, 17, $WS_GROUP)

; From $AddGUI
$ADD = GUICtrlCreateButton("ADD", 64, 88, 75, 25, $WS_GROUP)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Thornhunt,

If I told you that AutoIt capitialises all variables when it runs, would these lines give you a clue? ;)

; From $Form1
$Add = GUICtrlCreateButton("+", 0, 0, 19, 17, $WS_GROUP)

; From $AddGUI
$ADD = GUICtrlCreateButton("ADD", 64, 88, 75, 25, $WS_GROUP)

M23

well thats news to me, thankyou . and merry xmas

Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D

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...