Jump to content

Child Gui Controls not working


wfish
 Share

Recommended Posts

Let me start by letting you know I am brand new and this is my first script. In my page I have a button that opens another window the problem is that the controls in the child window do not work(set of their corresponding functions. Below is a simplified version of the code, thanks for your time.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\Documents and Settings\wayne.salmond\Desktop\buggedCases.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>

Local $mailWindow;
Local $mainWindow;

makeMainWindow();

Func makeMainWindow()
    Opt("GUIOnEventMode", 1)
$mainWindow = GUICreate("Bugged Tickets");
GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton")
$cancelButton = GUICtrlCreateButton("Cancel",100,150)
GUICtrlSetOnEvent($cancelButton,"cancelButton");
$emailWindowButton = GUICtrlCreateButton("emailWindow",200,150)
GUICtrlSetOnEvent($emailWindowButton,"openEmailWindow");
GUISetState(@SW_SHOW);
    While 1
  Sleep(500)  ; Idle around
WEnd
EndFunc


Func cancelButton()
  Exit
EndFunc


Func openEmailWindow()
    Opt("GUIOnEventMode", 1)
    $mailWindow = GUICreate("Email Bugged Tickets");
    GUICtrlCreateLabel("Sorry there are no result sets",10,10);
    GUICtrlCreateLabel("Please Run Get Cases on first page",10,40);
    $returnButton =GUICtrlCreateButton("Return",10,80);
    GUICtrlSetOnEvent($returnButton,"returntoMain");
    GUISetState(@SW_SHOW);
    While 1
  Sleep(500)  ; Idle around
    WEnd
    EndFunc
Func returntoMain()
    MsgBox(0,"return","button has been clicked");
    GUIDelete($mailWindow);
    Return
    EndFunc
Link to comment
Share on other sites

Your problem is: you have a While/Wend statement in each function. That's bad because your script will be stuck in that loop forever.

Advice: do not put such "endless loops" inside functions unless

- it is really needed

and

- you have any mean to quit the loop when needed

Here is the working code:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>

Local $mailWindow;
Local $mainWindow;

makeMainWindow();
While 1
  Sleep(500)  ; Idle around
WEnd

Func makeMainWindow()
    Opt("GUIOnEventMode", 1)
    $mainWindow = GUICreate("Bugged Tickets");
    GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton")
    $cancelButton = GUICtrlCreateButton("Cancel",100,150)
    GUICtrlSetOnEvent($cancelButton,"cancelButton");
    $emailWindowButton = GUICtrlCreateButton("emailWindow",200,150)
    GUICtrlSetOnEvent($emailWindowButton,"openEmailWindow");
    GUISetState(@SW_SHOW);
EndFunc


Func cancelButton()
  Exit
EndFunc


Func openEmailWindow()
    Opt("GUIOnEventMode", 1)
    $mailWindow = GUICreate("Email Bugged Tickets");
    GUICtrlCreateLabel("Sorry there are no result sets",10,10);
    GUICtrlCreateLabel("Please Run Get Cases on first page",10,40);
    $returnButton =GUICtrlCreateButton("Return",10,80);
    GUICtrlSetOnEvent($returnButton,"returntoMain");
    GUISetState(@SW_SHOW);
EndFunc
Func returntoMain()
    MsgBox(0,"return","button has been clicked");
    GUIDelete($mailWindow);
    Return
EndFunc

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

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