Jump to content
Sign in to follow this  
YoseMite

Program doesn't close

Recommended Posts

Hi,

I will make a simple application with 2 buttons...

The buttons work, but I can't close my application.

My code:

#include <GuiConstants.au3>
Opt("GUIOnEventMode",1)

; make window.........

;buttons
$start = GuiCtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start,"onstart")

$stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40)
GUICtrlSetOnEvent($stop,"onstop")


;FUNCTION for Button

Func onstart()
    MsgBox(0,"Hi", "You click on START")
EndFunc

;more .....


;close application

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Sorry for my bad language, I'm from Belgium.

Share this post


Link to post
Share on other sites

Hi,

I will make a simple application with 2 buttons...

The buttons work, but I can't close my application.

My code:

#include <GuiConstants.au3>
Opt("GUIOnEventMode",1)

; make window.........

;buttons
$start = GuiCtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start,"onstart")

$stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40)
GUICtrlSetOnEvent($stop,"onstop")
;FUNCTION for Button

Func onstart()
    MsgBox(0,"Hi", "You click on START")
EndFunc

;more .....
;close application

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Sorry for my bad language, I'm from Belgium.

<{POST_SNAPBACK}>

Have a look at the example in the Helpfile for GUICtrlSetOnEvent(). It shows how to detect the close window event.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have view de helpfile, and have something chance, but it still don't close... :(

<{POST_SNAPBACK}>

how do you want to close ?

With the stop button or with the X at the right top ?


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

I will make a simple application with 2 buttons...

The buttons work, but I can't close my application.

My code:

#include <GuiConstants.au3>
Opt("GUIOnEventMode",1)

; make window.........

;buttons
$start = GuiCtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start,"onstart")

$stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40)
GUICtrlSetOnEvent($stop,"onstop")
;FUNCTION for Button

Func onstart()
    MsgBox(0,"Hi", "You click on START")
EndFunc

;more .....
;close application

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Sorry for my bad language, I'm from Belgium.

<{POST_SNAPBACK}>

OnEvent functions are only called when the option GUIOnEventMode is set to 1 -  when in this mode GUIGetMsg is NOT used at all.

so why not use this instead of While GuiGetMsg() <> $GUI_EVENT_CLOSE?

GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
Func Quit ()
Exit
EndFunc
Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

OMG! :(

My pc is total crasht, and i haven't make a backup of my au3 files. :(

I start my project, but de application doesn't close.

Can someone please help my for the second time? :

My code:

#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)

;make form
GuiCreate("program",600, 400)


;make buttons
$start = GuiCtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start,"onstart")
$stop = GuiCtrlCreateButton("Stop", 180, 110, 100, 40)
GUICtrlSetOnEvent($stop,"onstop")

;functions -> buttons

Func onstart()
    MsgBox(0,"Hi", "You click on START")
EndFunc

Func onstop()
    MsgBox(0,"Hi", "You click on STOP")
EndFunc


GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
Func Quit ()
Exit
EndFunc

I doesn't close.

(The 'X' botton')

Sorry people... :)

Share this post


Link to post
Share on other sites

This is very important for my...

I have this topic view more than 10 times, but I don't get what I do wrong. :(

<{POST_SNAPBACK}>

You could have done what i answered previously in this very same threath :(

here's an example:

#include <GuiConstants.au3>
opt("GUIOnEventMode", 1)

;make form
GUICreate("program", 600, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

;make buttons
$start = GUICtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start, "onstart")
$stop = GUICtrlCreateButton("Stop", 180, 110, 100, 40)
GUICtrlSetOnEvent($stop, "onstop")

GUISetState(@SW_SHOW)

; Just idle around
While 1
    Sleep(10)
Wend

;functions -> buttons

Func onstart()
    MsgBox(0, "Hi", "You click on START")
EndFunc  ;==>onstart

Func onstop()
    MsgBox(0, "Hi", "You click on STOP")
EndFunc  ;==>onstop


GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
Func Quit()
    Exit
EndFunc  ;==>Quit 

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
            Exit
        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
        Case @GUI_CtrlId = $GUI_EVENT_RESTORE
            MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
    EndSelect
EndFunc  ;==>SpecialEvents

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)

;make form
GuiCreate("program",600, 400)
;make buttons
$start = GuiCtrlCreateButton("Start", 150, 110, 100, 40)
GUICtrlSetOnEvent($start,"onstart")
$stop = GuiCtrlCreateButton("Stop", 180, 110, 100, 40)
GUICtrlSetOnEvent($stop,"onstop")

;functions -> buttons

Func onstart()
    MsgBox(0,"Hi", "You click on START")
EndFunc

Func onstop()
    MsgBox(0,"Hi", "You click on STOP")
EndFunc
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
Func Quit ()
Exit
EndFunc

I doesn't close.

(The 'X' botton')

Sorry people... :(

<{POST_SNAPBACK}>

I am more surprised if you see the gui, yet unable to close it.

As in the sample that JdeB shows

; Just idle around
While 1
    Sleep(10)
Wend
This keeps the script alive. Something you are missing.

GUISetState(@SW_SHOW)

Another important thing missing. You will not see the Gui without it.

Helpfile is full of good information. You need to look closer, at the examples. :(

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...