Sign in to follow this  
Followers 0
John117

close a child GUI and not the Parent

4 posts in this topic

#1 ·  Posted (edited)

I have added the following code to my While 1 section

CODE

While 1

$msg = GUIGetMsg()

If $msg = $UpdateProfile Then _UpdateProfile()

Select

;Check if user clicked on a close button of any of the 2 windows

Case $msg = $GUI_EVENT_CLOSE

;Check if user clicked on the close button of the child window

If $msg = $ProfileForm1 Then

MsgBox(64, "Test", "Child GUI will now close.")

;Switch to the child window

GUISwitch($ProfileForm1)

;Destroy the child GUI including the controls

GUIDelete()

;Check if user clicked on the close button of the parent window

ElseIf $msg = $ParentWin Then

MsgBox(64, "Test", "Parent GUI will now close.")

;Switch to the parent window

GUISwitch($ParentWin)

;Destroy the parent GUI including the controls

GUIDelete()

EndIf

EndSelect

WEnd

When used I get:

If $msg = $ProfileForm1 Then

If $msg = ^ERROR

Error: variable used without being declared.

The function that creates the $ProfileForm1 is below the While 1. I have tried adding Dim $ProfileForm1. It clears the error but the close function does not work . . .

What am I doing wrong? :)

Edit: BTW - the whole point is to close the child only. If there is a easier way to close the open GUI that generated to close function, please let me know! :P

Edited by Hatcheda

Share this post


Link to post
Share on other sites



I have added the following code to my While 1 section

CODE

While 1

$msg = GUIGetMsg()

If $msg = $UpdateProfile Then _UpdateProfile()

Select

;Check if user clicked on a close button of any of the 2 windows

Case $msg = $GUI_EVENT_CLOSE

;Check if user clicked on the close button of the child window

If $msg = $ProfileForm1 Then

MsgBox(64, "Test", "Child GUI will now close.")

;Switch to the child window

GUISwitch($ProfileForm1)

;Destroy the child GUI including the controls

GUIDelete()

;Check if user clicked on the close button of the parent window

ElseIf $msg = $ParentWin Then

MsgBox(64, "Test", "Parent GUI will now close.")

;Switch to the parent window

GUISwitch($ParentWin)

;Destroy the parent GUI including the controls

GUIDelete()

EndIf

EndSelect

WEnd

When used I get:

If $msg = $ProfileForm1 Then

If $msg = ^ERROR

Error: variable used without being declared.

The function that creates the $ProfileForm1 is below the While 1. I have tried adding Dim $ProfileForm1. It clears the error but the close function does not work . . .

What am I doing wrong? :)

First) have you declared $ProfileForm1 as Global?

Second) You have to create it BEFORE the While loop


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Solved . . .

I droped the function and did this . . .Inside of my exsisting While1

CODE
If $msg = $UpdateProfile Then

$ProfileForm1 = GUICreate("Update Profile", 780, 380, 500, 400)

GUISetState(@SW_SHOW)

While 1

$msgg = GUIGetMsg()

If $msgg = $GUI_EVENT_CLOSE Then

GUIDelete($ProfileForm1)

ExitLoop

EndIf

WEnd

EndIf

Share this post


Link to post
Share on other sites

Solved . . .

I droped the function and did this . . .Inside of my exsisting While1

CODE
If $msg = $UpdateProfile Then

$ProfileForm1 = GUICreate("Update Profile", 780, 380, 500, 400)

GUISetState(@SW_SHOW)

While 1

$msgg = GUIGetMsg()

If $msgg = $GUI_EVENT_CLOSE Then

GUIDelete($ProfileForm1)

ExitLoop

EndIf

WEnd

EndIf

When it works, go with it. You can always play again later.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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