Advertisement
idsystems

CPP_RAD_Ejercicio12

May 18th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. /* ej12_Timers
  2. Ejemplo del uso de timers */  
  3.  #include <radc++.h>
  4.  
  5. Form form1("Prueba Timer - RAD C++ Ejemplo"); //create simple form
  6.  
  7. String timer1 = "Timer1"; //unique name of timer
  8. int x=0;                 //temporary variable to increase on timer notification
  9.  
  10. //create procedure for form to receive events                  
  11. FormProcedure form1Proc(FormProcArgs) {
  12.    
  13.     ON_CLOSE() { //close applciation when form is closed
  14.    
  15.         //remove timer when quitting application (remove all timers before exitting)
  16.         form1.removeTimer(timer1);
  17.        
  18.         Application.close();
  19.     }
  20.     ON_TIMER_NOTIFICATION(timer1) { //when timer named 'Timer1' notifies
  21.         //increase value of variable 'x' and assgn it to caption/title of form
  22.         //NOTE : str returns string presentation of a numeric value
  23.         form1.caption = str(++x);
  24.     }
  25.  
  26.     return 0;
  27. }
  28.  
  29. rad_main()
  30.  
  31.         //attach procedure to the form
  32.         form1.procedure = form1Proc;
  33.        
  34.         //Set new timer, set notification time to 1 second, which will notify our Form after
  35.         //each second continously until timer is not removed
  36.         form1.setTimer(timer1, 1 * SECONDS);
  37.        
  38.         //MOREOVER:
  39.         //1. you may pass direct value in terms of milliseconds e.g. 1000 in this case which is 1 second
  40.         //2. you can use 2 * MINUTES which is 2 minutes, or 2 * HOURS which is repectively 2 hours
  41.  
  42. rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement