Jump to content
Sign in to follow this  

Need help from you GUI experts!

Recommended Posts


I have a gui that has various buttons and controls, etc. When a user clicks the "Add" button, I want them to then have two choices... Add Folder or Add File.

So I guess I'm envisioning a 2nd GUI opening up with those selections, then a selectfolder/open file dialogue depending on their choice. The result of that then gets returned to the script.

I suppose I'm just clueless on how to work that 2nd GUI (or whatever) in. Suggestions or pointers? Thanks.


Share this post

Link to post
Share on other sites

I am not an expert at GUI but this is what i made for a password form(being used in 1 of my project).

This should get you going, look through the script carefully and see how the GUI is being create and delete. The way I am doing you won't encounter any bug.

Opt("GUIOnEventMode", 1)
Global $Inuse = False, $passwordfrm, $string1, $string2, $password = ""
$mainfrm = GUICreate("Main Form", 200, 35, -1, -1, -1)
$button0 = GUICtrlCreateButton("Password", 1, 1, 98, 30)
$button1 = GUICtrlCreateButton("Check", 99, 1, 98, 30)
GUICtrlSetFont($button0, 9, 400, 0, "Tahoma")
GUICtrlSetFont($button1, 9, 400, 0, "Tahoma")
GUICtrlSetOnEvent($button0, "_PasswordGUI")
GUICtrlSetOnEvent($button1, "_ShowPassword")
GUISetFont(9, 400, 0, "Tahoma")
While 1
Func _PasswordGUI()
    If $Inuse = True Then Return
    $Inuse = Not $Inuse
    $passwordfrm = GUICreate("Password Protection", 400, 60, -1, -1, -1, -1, $mainfrm)
    $label1 = GUICtrlCreateLabel("Type Password: ", 1, 1, 120, 20, $SS_CENTER)
    $label2 = GUICtrlCreateLabel("Confirm Password: ", 1, 32, 120, 20, $SS_CENTER)
    $string1 = GUICtrlCreateInput("", 121, 3, 210, 20, $ES_PASSWORD)
    $string2 = GUICtrlCreateInput("", 121, 32, 210, 20, $ES_PASSWORD)
    $setbutton = GUICtrlCreateButton("SET", 336, 3, 60, 51, $BS_VCENTER)
    GUICtrlSetFont($label1, 11, 400, 0, "Tahoma")
    GUICtrlSetFont($label2, 11, 400, 0, "Tahoma")
    GUICtrlSetFont($string1, 9, 400, 0, "Tahoma")
    GUICtrlSetFont($string2, 9, 400, 0, "Tahoma")
    GUICtrlSetFont($setbutton, 11, 400, 0, "Tahoma")
    GUICtrlSetOnEvent($setbutton, "_SetPassword")
    GUISetOnEvent($GUI_EVENT_CLOSE, "Subdel")
EndFunc   ;==>_PasswordGUI
Func _ShowPassword()
    MsgBox(64, "Password", $password)
EndFunc   ;==>_ShowPassword
Func Subdel()
    $Inuse = Not $Inuse
EndFunc   ;==>Subdel
Func _PasswordChk()
    If StringLen(GUICtrlRead($string1)) <> StringLen(GUICtrlRead($string2)) Then
        MsgBox(64, "Password Check", "Please confirm both of your password")
    ElseIf GUICtrlRead($string1) <> GUICtrlRead($string2) Then
        MsgBox(64, "Password Check", "Please confirm both of your password")
    Return GUICtrlRead($string2)
EndFunc   ;==>_PasswordChk
Func _SetPassword()
    Local $ButtonPos = WinGetPos($passwordfrm, "")
    If IsNumber(_PasswordChk()) = 0 Then
        $password = GUICtrlRead($string2)
        ToolTip("Password was set, please remember", $ButtonPos[0] + 370, $ButtonPos[1] + 55, "Result", 1, -1)
        Return $password
        ToolTip("Password was not set", $ButtonPos[0] + 370, $ButtonPos[1] + 55, "Result", 1, -1)
EndFunc   ;==>_SetPassword
Func Quit()
EndFunc   ;==>Quit

Share this post

Link to post
Share on other sites

Thank you very much for the fast response and example!

I ran it and that's pretty much exactly what I want, so thank you.

I'd like it so the parent window was totally disabled while the child window is active, but I'll take a look in the help files to see if I can figure that out. You've given me exactly what I need to get going.

Thanks again.


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