Jump to content
Sign in to follow this  
Lightning87

Function is running in the front

Recommended Posts

Lightning87

Hello people,

I was trying to make a qountdown function but its running all the time in the front.

So all my buttons are dissabled.

I hope someone can help me!

Greetz Barry

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Timers.au3>

Opt('MustDeclareVars', 1)


    Local $msg, $msg1, $gui, $basti_stay, $Verzenden, $passwd, $goed, $fout, $totaal, $Label1, $Label2, $j
    Local $goed1
    Local $check1

    $gui = GUICreate("Background", 1039, 680) ; will create a dialog box that when displayed is centered
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    $basti_stay = GUICtrlCreatePic("Q:\Scripts\Test1.bmp", 0, 0, 1039, 645)
    GUICtrlSetState(-1, $GUI_DISABLE)

    $Verzenden = GUICtrlCreateButton("Verzenden", 470, 650, 100, 25)
    $Label1 = GUICtrlCreateLabel("", 580, 650, 76, 28)
    $Label2 = GUICtrlCreateLabel("", 600, 650, 76, 28)


;~ links
GUIStartGroup()
    $check1 = GUICtrlCreateRadio("Av", 293, 49, 37, 26)

qountdown()

Func password()
    $passwd = InputBox("Login", "Voer je wachtwoord in.", "", "*")
    If $passwd = 'test' Then
    uitslag()
    GUISetState(@SW_SHOW)
Else
    GUISetState(@SW_HIDE)
    MsgBox(0, "Inloggen mislukt", "Wachtwoord onjuist, probeer dit niet meer dan 3x..")
    password()
EndIf
EndFunc

Func uitslag()

    GUICreate("Uitslag:", 150, 320)

    If GUICtrlRead($check1) = 1 Then
        $goed1 = 1
        $goed = GUICtrlCreateLabel ("1.  goed", 10, 10)
    Else
        $goed1 = 0
        $fout = GUICtrlCreateLabel ("1.  fout", 10, 10)
    EndIf

    $totaal = ($goed1)
    GUICtrlCreateLabel ("Totaal goed:", 10, 290)
    GUICtrlCreateLabel ($totaal, 75, 290)
    GUICtrlCreateLabel ("van de 36", 88, 290)

EndFunc
func qountdown()
    GUICtrlSetData($Label1, 5)
    GUICtrlSetData($Label2, 00)

    GUICtrlSetData($Label1, 4)
    For $j = 60 to 1 Step -1
    GUICtrlSetData($Label2, $j)
    Sleep(1000)
    Next
    GUICtrlSetData($Label1, 3)
    For $j = 60 to 1 Step -1
    GUICtrlSetData($Label2, $j)
    Sleep(1000)
    Next
    GUICtrlSetData($Label1, 2)
    For $j = 60 to 1 Step -1
    GUICtrlSetData($Label2, $j)
    Sleep(1000)
    Next
    GUICtrlSetData($Label1, 1)
    For $j = 60 to 1 Step -1
    GUICtrlSetData($Label2, $j)
    Sleep(1000)
    Next
    GUICtrlSetData($Label1, 0)
    For $j = 60 to 1 Step -1
    GUICtrlSetData($Label2, $j)
    Sleep(1000)
    Next
    GUICtrlSetData($Label2, "")
    password()
EndFunc

    While 1

    $msg = GUIGetMsg()
    Select
    Case $msg = $Verzenden
        MsgBox(4096, "Loading", "Gegevens zijn opgeslagen. uitslag word geladen...", 5)
        password()
    EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

Share this post


Link to post
Share on other sites
Scriptonize

Hi,

This behavior is caused by the flow of your code.

You start running the countdown function and after it has reached the value '0',

you start the while loop. In this loop you start fetching GUI messages.

So while being in the countdown loop no GUI events (messages) are processed.

You need to rearrange the code.

First create the GUI, then start a loop fetching GUI messages with a countdown function.

Hope this helps.


If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites
Manjish

You can get help here


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites
Lightning87

Thank you!

i fixed it >_<

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  

×