Sign in to follow this  
Followers 0
5t0n3r

Getting Cancel Button to work

3 posts in this topic

Hi, I have an issue getting the cancel button working in multiple tabs.

I would like to re-use the bit of scripting I have for the $cancel variable but I'm wondering if I can re-use that var in the tabs.

My goal is not to write a canceling routine for each and every tab as there will be in the end about 100 tabs in total.

Code is below. Any help would be appreciated.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $cancel=""

$gui = GUICreate("Add / Remove Employee Process", 500, 400)
$tab = GUICtrlCreateTab(-10, -22, 520, 430)

; Main Menu Page
$main1Page1 = GUICtrlCreateTabItem("mainmenu1")
$main1Btn1 = GUICtrlCreateButton("New Employee", 70, 100, 150, 60)
$main1Btn2 = GUICtrlCreateButton("Terminated Employee", 280, 100, 150, 60)
$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("Choose this option for the" & @CRLF & "New Employee checklist.", 70, 200)
GUICtrlCreateLabel("Choose this option for the" & @CRLF & "Terminated Employee checklist.", 280, 200)
; End Main Menu page

; New Employee Page 1
$new1Page1 = GUICtrlCreateTabItem("new_employee_p1")
$new1Btn1 = GUICtrlCreateButton("< Back", 260, 370, 75, 25)
$new1Btn2 = GUICtrlCreateButton("Next >", 335, 370, 75, 25)
$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("New Employee Page 1", 100, 200)
; End New Employee Page 1

; Terminated Employee Page 1
$ter1Page1 = GUICtrlCreateTabItem("ter_employee_page1")
$ter1Btn1 = GUICtrlCreateButton("< Back", 330, 360, 75, 25)
$ter1Btn2 = GUICtrlCreateButton("Next >", 410, 360, 75, 25)
$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("Terminated Employee Page 1", 100, 200)
; End Terminated Employee Page 1

GUICtrlSetState($main1Page1, $GUI_SHOW)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
;        Case - 3
;            Exit
        Case $cancel
            $answer = MsgBox(32 + 4, "Exit Program", "Are you sure you want to EXIT the program?" & @CRLF & "All entered information will be lost.")
            Switch $answer
                Case 6; Yes
                    Exit
                Case 7; No
            EndSwitch
        Case $main1Btn1
            GUICtrlSetState($new1Page1, $GUI_SHOW)
        Case $main1Btn2
            GUICtrlSetState($ter1Page1, $GUI_SHOW)
        Case $new1Btn1
            GUICtrlSetState($main1Page1, $GUI_SHOW)
        Case $ter1Btn1
            GUICtrlSetState($main1Page1, $GUI_SHOW)

    EndSwitch

WEnd

Share this post


Link to post
Share on other sites



try this one:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $cancel=""

$gui = GUICreate("Add / Remove Employee Process", 500, 400)
$tab = GUICtrlCreateTab(-10, -22, 520, 380)

; Main Menu Page
$main1Page1 = GUICtrlCreateTabItem("mainmenu1")
$main1Btn1 = GUICtrlCreateButton("New Employee", 70, 100, 150, 60)
$main1Btn2 = GUICtrlCreateButton("Terminated Employee", 280, 100, 150, 60)
;$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("Choose this option for the" & @CRLF & "New Employee checklist.", 70, 200)
GUICtrlCreateLabel("Choose this option for the" & @CRLF & "Terminated Employee checklist.", 280, 200)
; End Main Menu page

; New Employee Page 1
$new1Page1 = GUICtrlCreateTabItem("new_employee_p1")
$new1Btn1 = GUICtrlCreateButton("< Back", 260, 330, 75, 25)
$new1Btn2 = GUICtrlCreateButton("Next >", 335, 330, 75, 25)
;$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("New Employee Page 1", 100, 200)
; End New Employee Page 1

; Terminated Employee Page 1
$ter1Page1 = GUICtrlCreateTabItem("ter_employee_page1")
$ter1Btn1 = GUICtrlCreateButton("< Back", 330, 330, 75, 25)
$ter1Btn2 = GUICtrlCreateButton("Next >", 410, 330, 75, 25)
;$cancel = GUICtrlCreateButton("Cancel", 420, 370, 75, 25)
GUICtrlCreateLabel("Terminated Employee Page 1", 100, 200)
; End Terminated Employee Page 1
GUICtrlCreateTabitem ("")
$cancel = GUICtrlCreateButton("Cancel", 370, 370, 75, 25)
GUICtrlSetState($main1Page1, $GUI_SHOW)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
;        Case - 3
;            Exit
        Case $cancel
            $answer = MsgBox(32 + 4, "Exit Program", "Are you sure you want to EXIT the program?" & @CRLF & "All entered information will be lost.")
            Switch $answer
                Case 6; Yes
                    Exit
                Case 7; No
            EndSwitch
        Case $main1Btn1
            GUICtrlSetState($new1Page1, $GUI_SHOW)
        Case $main1Btn2
            GUICtrlSetState($ter1Page1, $GUI_SHOW)
        Case $new1Btn1
            GUICtrlSetState($main1Page1, $GUI_SHOW)
        Case $ter1Btn1
            GUICtrlSetState($main1Page1, $GUI_SHOW)

    EndSwitch

WEnd

Share this post


Link to post
Share on other sites

That did it. Thanks!

:D Your Kung Fu is good!

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