Sign in to follow this  
Followers 0
sleepydvdr

How can I close an "About" box without exiting the program? [Solved]

6 posts in this topic

#1 ·  Posted (edited)

Hello all,

I have a small working program and I created a function to produce an About box (called from the Main). However, when I click the red X, it exits the entire program instead of just the box.

Here's the code for the About box:

Func _About()
    Local $Form2, $Pic1, $Pic2, $i, $Label1, $Label2, $about

    FileInstall("src\website.jpg", @AppDataDir & "\MassiveRun\website.jpg", 1)

    $Form2 = GUICreate("About MassiveRun", 303, 128, -1, -1)

    $Pic2 = GUICtrlCreatePic(@AppDataDir & "\MassiveRun\website.jpg", 0, 110, 300, 15)
    GUICtrlSetCursor (-1, 0)
    $Pic1 = GUICtrlCreatePic(@AppDataDir & "\MassiveRun\FusionSolidSplash.jpg", 0, 0, 300, 110)
    $Label1 = GUICtrlCreateLabel("MassiveRun Software Installer", 30, 50, 150, 15)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $Label2 = GUICtrlCreateLabel("Version 1.1", 30, 70, 100, 15)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUISetState(@SW_SHOW)

    $i = 0

    While 1
        Do

        $about = GUIGetMsg()

        Select
            Case $about = $GUI_EVENT_CLOSE
                exit
            Case $about = $Pic2
                _IECreate("http://www.fusionsolid.com", 1)
        EndSelect
        until $i = 2

    WEnd
EndFunc

I have been concentrating on the "Case $about = $GUI_EVENT_CLOSE" section. I have tried exiting the loop and closing the window and tried Exit 0, Exit 1, Exit 2, etc.

Am I concentrating on the right part? Does anyone have any suggestions?

Edited by sleepydvdr

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

After GUISetState()

replace the While...WEnd with

Do
        $about = GUIGetMsg()
        If $about = $GUI_EVENT_CLOSE Then
            GUIDelete($Form2)
            Return
        EndIf
        If $about = $Pic2 Then
            _IECreate("http://www.fusionsolid.com", 1,1,0)
        EndIf
 Until $about = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

After GUISetState()

replace the While...WEnd with

That worked perfectly. Thank you, taietel!


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

I think switch statements work really nice with this type of loop:

While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop ; Get out of the loop
            Case $Pic2
                _IECreate("http://www.fusionsolid.com", 1)
        EndSwitch
    WEnd
    GUIDelete($Form2); Delete the GUI before we return
Although the concepts are similar.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Yes, that is another good way to solve it. The missing link for me was I didn't know about GUIDelete. On my previous efforts, I was trying to use WinClose.

Thanks for the responses...


#include <ByteMe.au3>

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