Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ej12_Timers
- Ejemplo del uso de timers */
- #include <radc++.h>
- Form form1("Prueba Timer - RAD C++ Ejemplo"); //create simple form
- String timer1 = "Timer1"; //unique name of timer
- int x=0; //temporary variable to increase on timer notification
- //create procedure for form to receive events
- FormProcedure form1Proc(FormProcArgs) {
- ON_CLOSE() { //close applciation when form is closed
- //remove timer when quitting application (remove all timers before exitting)
- form1.removeTimer(timer1);
- Application.close();
- }
- ON_TIMER_NOTIFICATION(timer1) { //when timer named 'Timer1' notifies
- //increase value of variable 'x' and assgn it to caption/title of form
- //NOTE : str returns string presentation of a numeric value
- form1.caption = str(++x);
- }
- return 0;
- }
- rad_main()
- //attach procedure to the form
- form1.procedure = form1Proc;
- //Set new timer, set notification time to 1 second, which will notify our Form after
- //each second continously until timer is not removed
- form1.setTimer(timer1, 1 * SECONDS);
- //MOREOVER:
- //1. you may pass direct value in terms of milliseconds e.g. 1000 in this case which is 1 second
- //2. you can use 2 * MINUTES which is 2 minutes, or 2 * HOURS which is repectively 2 hours
- rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement