Jump to content

Code Help ?


Negro
 Share

Recommended Posts

I pressed the Start button, start the program.Everything is working but I press start the button, the clicked, don't start Look at the code to understand the codes.

I'm sorry,for bad my english :mellow:

$Form1 = GUICreate("TimerDiff", 261, 71, 192, 124)
$Label1 = GUICtrlCreateLabel("00", 8, 8, 16, 17)
$Label2 = GUICtrlCreateLabel(":", 32, 7, 7, 17)
$Label3 = GUICtrlCreateLabel("00", 40, 8, 16, 17)
$Label4 = GUICtrlCreateLabel(":", 64, 7, 7, 17)
$Label5 = GUICtrlCreateLabel("00", 72, 8, 16, 17)
$Button1 = GUICtrlCreateButton("START", 8, 32, 75, 25)
$Button2 = GUICtrlCreateButton("STOP", 96, 32, 75, 25)
$Button3 = GUICtrlCreateButton("EXIT", 176, 32, 75, 25)
GUISetState(@SW_SHOW)
Local $TimerInit
Local $TimerStart = 0
Local $iSec_Temp
Local $iTime,$iHour,$iMin,$iSec
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case -3
   Exit
  Case $Button1
   $TimerInit = TimerInit()
   $TimerStart = 1
  Case $Button2
   $TimerInit = 0
   $TimerStart = 0
EndSwitch
If $TimerStart = 1 Then
        $iTime = Int(TimerDiff($TimerInit)/100)/10
        $iHour=Int($iTime/3600)
        $iMin = Int(($iTime-$iHour*3600)/60)
        $iSec = Int($iTime)-$iHour*3600-$iMin*60
        If $iHour < 10 Then $iHour='0'&$iHour
        If $iMin < 10 Then $iMin='0'&$iMin
        If $iSec < 10 Then $iSec='0'&$iSec
  If $iSec_Temp <> $iSec Then
   $iSec_Temp = $iSec
   GUICtrlSetData($Label5,$iSec)
   GUICtrlSetData($Label3,$iMin)
   GUICtrlSetData($Label1,$iHour)
  EndIf
EndIf
WEnd
Edited by TURK34

[font="'Times New Roman"]Everything will be fine[/font]

Link to comment
Share on other sites

The only thing I can see that doesn't work is the exit button, which can be fixed like this:

Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button3
            Exit
        Case $Button1
            $TimerInit = TimerInit()
            $TimerStart = 1
        Case $Button2
            $TimerInit = 0
            $TimerStart = 0
    EndSwitch
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...