Jump to content

Child Window


Recommended Posts

I've included a code snippet...I tried to delete what's extraneous to the problem.

My back button doesn't close the child window.

I know the CleanUpChild is called. I tested it with a message box. But for some reason the WinClose doesnt work (I tried WinKill too). I also tried it with the "" parameter and didn't work either.

I can post the full code if you need it to help.

Thanks

#include <guiconstants.au3>
#include <string.au3>
#include <Array.au3>

;setup and initialization


Const $ENABLE=1
Const $DISABLE=0

;set Event Mode so can do REGULAR Windows type Events
Opt("GuiOnEventMode", $ENABLE)

;use _ArrayInsert to put letters in array...had problems using subscripting

;used to hold the control id of the button of each letter
dim $letter[25]

;used for main screen, made global so can create child to it
Global $mywindow

;used to center window
$centered=-1

;used to place buttons (i.e. letters)
$Xstart=10
$Ystart=10
$Xoffset=50
$Yoffset=35

;used to let us know when to go to the next line
;to place another row of buttons
$count=0

$mywindow=GUICreate("Fun Time Learning - Main Screen",400,400,$centered,$centered)


GUISetState (@SW_MAXIMIZE)
GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
;*****

While 1
;using response to Events (normal windows way)
;so just do nothing here
 sleep(10)
Wend
;end of MAIN

Func LetterChosen()
;Function doesn't return any value
;it just displays the letter chosen
;from the display (A-Z)
;and a picture
;also says the sound
  $chosen_letter=ConvertToLetter(@Gui_CtrlId)
  MyCreateLetterChosenGUI($chosen_letter)
  $mysoundletter=SoundPlay(ChosenLetterSound($chosen_letter),1)
;$mysoundword=SoundPlay(GetLetterWord(@GUI_CTRLID),1)
  
EndFunc

Func MyCreateLetterChosenGUI($id)
 ;display the letter by itself
 ;display a pic too with a label
  $storage=@Gui_WinHandle
  $myhandle=GUICreate("Fun Time Learning - Letter Chosen",800,600,0,0,$mywindow)
 ;change font to Display letter Chosen
  $font="Comic Sans MS"
  GUISetFont (48, 400, $font)
  $mylabel=GUICtrlCreateLabel($id,400,50,400,500)
  $mypic=GUICtrlCreatePic(ChosenLetterPic($id),100,150,128,128)
  $mypiclabel=GUICtrlCreateLabel(GetLetterWord(@GUI_CTRLID), 300,300,200,200,$mywindow) 
  $back_buttonID=GUICtrlCreateButton("Back",200,500,100,100)
  GUICtrlSetOnEvent(-1, "CleanUpChild")
  GUISetState (@SW_MAXIMIZE)
  
EndFunc



Func CleanUpChild()
        WinClose("Fun Time Learning - Letter Chosen")
EndFunc
Link to comment
Share on other sites

Hi,

Try to change the line:

GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

into:

GuiSetOnEvent($GUI_EVENT_CLOSE, "CleanUpChild")

Regards,

-Sven

EDIT:

Just a question about your line: GUICtrlSetOnEvent(-1, "CleanUpChild")

I couldn't find the GUI_EVENT -1 in the GUIConstants.au3. What function does it have?

Edited by SvenP
Link to comment
Share on other sites

Hi,

Try to change the line:

GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

into:

GuiSetOnEvent($GUI_EVENT_CLOSE, "CleanUpChild")

Regards,

-Sven

EDIT:

Just a question about your line:  GUICtrlSetOnEvent(-1, "CleanUpChild")

I couldn't find the GUI_EVENT -1 in the GUIConstants.au3.  What function does it have?

<{POST_SNAPBACK}>

I think that defaults it to the last control, that's what the example had in the help file
Link to comment
Share on other sites

What exactly are you doing here? You asked me to help but that snippet is missing alot and I can't figure out the big picture.

In addition, it's alot easier for script writing just to do a:

While 1

$msg = GuiGetMsg()

Select

EndSelect

WEnd

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

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