Jump to content
Sign in to follow this  
Guest fafot

How to stop timer when combo box is clicked

Recommended Posts

Guest fafot

I created a combo box. I also have a timer loop.

My timer is set for 5 seconds so I have to be quick if I want to select any other value - and I don't like this... My question is:

How to get a control that will stop the timer at the moment the combo box is clicked?

Thank you.

Share this post


Link to post
Share on other sites

I don't think you can actaully 'stop' a timer. You can just reset it. Each time you 'call' it, or whatever you want to say, it resets it so.

$begin = TimerInit()
sleep(3000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)
$begin = TimerInit()
sleep(4000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)

First mesage box will be about 3000 ms and the second will be about 4000, as I said before each time oyu start a timer it resets it. But you can have 2 timers going at the same time I think, eg.

$Time_1 = TimerInit()
$Time_2 = TimerInit()

Not sure about that though.

Edit: You can have 2 timers running at the same time.

Edited by Burrup

qq

Share this post


Link to post
Share on other sites
Guest fafot

Sorry I did not explained myself correctly:

GUICtrlSetData($SizeRam_3,"48|64|96|128|Auto19","Auto19")

For $i = 05 to 0 step -1

      sleep(1000)

      GUICtrlSetData($Timer3, $i)

;;; Here I MUST select a value to get out of the loop

      $ConvRam = GUICtrlRead($SizeRam_3)

      if $convRam <> "Auto19" Then ExitLoop

Next

If $I < 0 then

  Call ("SetRamDrive")

else

  While 1

      $msg = GUIGetMsg()

  WEnd

EndIf

By doing this I exited the timer loop and the timer stop counting but it happens only WHEN I select a value from the combo box and NOT when I click on it. I am looking for solution that will stop the timer - get me out of the loop - when I click on the combo box WITHOUT selecting any value.

Share this post


Link to post
Share on other sites

Ahhh my bad. I'll use an example instead so that you can modify it for your self :).

While 1
   If GUICtrlRead($test) = "blah" Then
    ;Blah
   EndIf
Wend

That will do "blah" when the combo equals "blah". If you wanted it to do "blah" whenever you select a value you can use GUICtrlRead($test) <> "", which ensure that whenever you select a value it will do whatever, provided there isn't and entry in the list box with the contents "" :D. If you click on it and move your mouse over the contents it will perform "blah". Not when you click it.

If you did want it when you click it. You would use GUIGetMsg()

While 1
   $msg = GuiGetMsg()
   If $msg = $test Then
    ;Blah
   EndIf
WEnd
Edited by Burrup

qq

Share this post


Link to post
Share on other sites
Guest fafot

Tx for the answer. It still does not do the job the way I would like it but its ok for me.

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