Jump to content

Why won't this close.


Recommended Posts

; Dan's Menu
; August 2, 2006

#include <GuiConstants.au3>

; GUI
GuiCreate("Dan's Main Menu", 400, 400)
GuiSetIcon(@SystemDir & "\notepad.exe", 0)
; MENU
$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("About")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)

; TAB
GuiCtrlCreateTab(1, 0, 400, 150)
GuiCtrlCreateTabItem("Intro")
GuiCtrlCreateLabel("Welcome to Dan's Menu Program. " &@crlf &"Of course if you trust me you would be seeing this right now." &@crlf &"So hats off you too. So, this is like my first favorite program I wrote. Sweet eh? Well not really, but I still like it!", 20, 40)
GuiCtrlCreateTabItem("Test")
GuiCtrlCreateLabel("I'm like testing.", 20, 40)
GuiCtrlCreateTabItem("About")

; GUI MESSAGE LOOP
GuiSetState()

While 1
    $msg = GUIGetMsg()
   

    Select
       
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
            If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu)

        Case $msg = $exititem
            ExitLoop

        Case $msg = $aboutitem
            Msgbox(0,"About Dan's Menu","This menu was programmed by Dan. This is copyrighted so if you have the same exact code and you claim as yours. Well then your ripping. Got questions? Email me at dan@zetastyles.com!")
     
        Case $msg = $GUI_EVENT_CLOSE
      MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
    EndSelect
WEnd

When I click the red X top right of it It will not close. Please help.

[center]Cookyx.com :: Simple LAN Chat[/center]

Link to comment
Share on other sites

@John, thanks, that is what I stated.

I've had that happen before. I don't know what causes it.

Can you get anything to happen when you get that $msg ?

Yes, it shows a msgbox in the first script. A msgBox is not going to close the script though. This is why we have an Exit keyword so we can finish the script conditionally. Or even use ExitLoop if you want to continue down the script. With Exitloop You may use GUIDelete() to close the Gui to continue on with the script.

Does 'Exit' work ?

Ofcourse Exit works.

:whistle:

Link to comment
Share on other sites

Here is the whole script. (took me a whole 6 seconds to figure this out) :whistle:

; Dan's Menu
; August 2, 2006

#include <GuiConstants.au3>

; GUI
GuiCreate("Dan's Main Menu", 400, 400)
GuiSetIcon(@SystemDir & "\notepad.exe", 0)
; MENU
$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("About")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)

; TAB
GuiCtrlCreateTab(1, 0, 400, 150)
GuiCtrlCreateTabItem("Intro")
GuiCtrlCreateLabel("Welcome to Dan's Menu Program. " &@crlf &"Of course if you trust me you would be seeing this right now." &@crlf &"So hats off you too. So, this is like my first favorite program I wrote. Sweet eh? Well not really, but I still like it!", 20, 40)
GuiCtrlCreateTabItem("Test")
GuiCtrlCreateLabel("I'm like testing.", 20, 40)
GuiCtrlCreateTabItem("About")

; GUI MESSAGE LOOP
GuiSetState()

While 1
    $msg = GUIGetMsg()
   

    Select
       
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
            If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu)

        Case $msg = $exititem
            ExitLoop

        Case $msg = $aboutitem
            Msgbox(0,"About Dan's Menu","This menu was programmed by Dan. This is copyrighted so if you have the same exact code and you claim as yours. Well then your ripping. Got questions? Email me at dan@zetastyles.com!")
     
        Case $msg = $GUI_EVENT_CLOSE
            MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
            Exit
    EndSelect
WEnd

Enjoy!

- Dan [Website]

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