Sign in to follow this  
Followers 0
PHPWarner

GUI Problem, Really Need Help

7 posts in this topic

Hello friends,

I need to little help for find a solution to my problem.

I've 2 simple GUI, the first one is main GUI included about button and quit button.

The second GUI is the about box, which contains product information and OK button which I want to close only about GUI and then return to the main GUI.

Below is the sample codes:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Main", 192, 64, 192, 114)
$About = GUICtrlCreateButton("About", 16, 16, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Quit", 96, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $About
            $Form2 = GUICreate("About", 324, 241, 425, 149)
            GUISetIcon("D:\006.ico")
            $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
            $Image1 = GUICtrlCreatePic("", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
            $Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
            $Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
            $Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Close_Button = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
            GUISetState(@SW_SHOW)

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        Exit
                    Case $Close_Button
                        Exit ; this is closing app completely, I want to close only about GUI and then return to the main GUI
                EndSwitch
            WEnd
    EndSwitch
WEnd

So many thanks in advice.

Share this post


Link to post
Share on other sites



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Close_Button
            GUIDelete($Form2)
            ExitLoop
;           Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Thank you so much.

Share this post


Link to post
Share on other sites

I'm facing the same problems as well. I tried what Yashield suggested, but only worked once.

First I run the script, when I click the "About" Button it worked fine. The About Box showed up.

After that, I closed the "About" Box. Then, I tried clicking the "About" Button again. Yet! Nothing showed up!

What's wrong?

Share this post


Link to post
Share on other sites

I believe it is because the GUI is deleted. It might be easier to set the gui for the "about" at

GUISetState(@SW_HIDE, $Form2) when it is first created

then when the button is clicked to bring up the gui use

GUISetState(@SW_SHOW, $Form2)

the close button would be a simple

GUISetState(@SW_HIDE, $Form2) again.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Also take a look in the help file at GUISwitch()


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

Hi to all.

PHPWarner & PlatinumHex This works fine for me.

#NoTrayIcon
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>

$Form1 = GUICreate("MAIN GUI", 265, 137) ;creating MAIN GUI
$Button1 = GUICtrlCreateButton("About", 24, 72, 73, 25, $WS_GROUP)
$nope = GUICtrlCreateButton("Exit", 168, 72, 73, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("This is a GUI 1`S LABEL", 72, 24, 120, 17)
$hfilemenu=GUICtrlCreateMenu("File")
$hfilemenu_fisrtitem=GUICtrlCreateMenuItem("About",$hfilemenu)
GUICtrlCreateMenuItem("",$hfilemenu)
$hfilemenu_itemEXIT=GUICtrlCreateMenuItem("Exit",$hfilemenu)
GUICtrlCreateMenuItem("",$hfilemenu)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _haqqda()
        Case $nope
            $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15)
            If $hanswer="1" Then
                Exit
            EndIf
        Case $hfilemenu_fisrtitem
            _haqqda()
        Case $hfilemenu_itemEXIT
            $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout= 15 sec
            If $hanswer="1" Then    ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :)
                Exit
            EndIf




    EndSwitch
WEnd


Func _haqqda()
GUIDelete($Form1) ;deleting $Form1 . This is a previous GUI .
$Form2 = GUICreate("About", 324, 234)   ;creating second GUI .In that case this is a <ABOUT> GUI.
$Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD))
$Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD))
$Label4 = GUICtrlCreateLabel("Comments: ", 16, 160, 53, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD))
$Label3 = GUICtrlCreateLabel("sh3llc043r", 16, 136, 48, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD))
$Button2 = GUICtrlCreateButton("&OK", 112, 208, 75, 25, BitOR($WS_TABSTOP,$WS_VISIBLE,$WS_CHILD))
$Image1 = GUICtrlCreatePic(@SystemDir& "\oobe\html\mouse\images\pisa.jpg", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState()
SoundPlay(@WindowsDir & "\media\tada.wav",0) ;play tada.wav when About GUI Appears :) WIN XP SP2


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg


                    Case $GUI_EVENT_CLOSE
                        GUIDelete($Form2)

                    _aka()



        Case $Button2
GUIDelete($Form2)   ;deleting <ABOUT> GUI
_aka()  ;creating 1`st GUI again. For func see below => Func _aka()

EndSwitch


WEnd

EndFunc;<==>_haqqda()

Func _aka()
$Form1 = GUICreate("MAIN GUI", 265, 137)
$Button1 = GUICtrlCreateButton("About", 24, 72, 73, 25, $WS_GROUP)
$nope = GUICtrlCreateButton("Exit", 168, 72, 73, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("This is a GUI 1`S LABEL", 72, 24, 120, 17)
$hfilemenu=GUICtrlCreateMenu("File")
$hfilemenu_fisrtitem=GUICtrlCreateMenuItem("About",$hfilemenu)
GUICtrlCreateMenuItem("",$hfilemenu)
$hfilemenu_itemEXIT=GUICtrlCreateMenuItem("Exit",$hfilemenu)
GUICtrlCreateMenuItem("",$hfilemenu)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $hfilemenu_fisrtitem
            _haqqda()
        Case $hfilemenu_itemEXIT
    ;confirm exit
            $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout=15 sec
            If $hanswer="1" Then    ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :)
                Exit
            EndIf

        Case $Button1

            _haqqda()
        Case $nope
            $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout=15 sec
            If $hanswer="1" Then    ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :)
                Exit
                EndIf




    EndSwitch
WEnd
EndFunc; <===> _aka()

[size="5"] [/size]

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