Add Active Object to the first program to make the ball

xiaoxiao2021-03-06  37

1. First define a Ceriodic * itimer; active object, Cperiodic inherits in CACTIVE, which is recommended to use CACTIVE in Symbian C without using RTimer. 2.iTimer-> Start (TTimeIntervalMicroSeconds32 aDelay, TTimeIntervalMicroSeconds32 anInterval, TCallBack aCallBack); TTimeIntervalMicroSeconds32 generated from the first event to the active object star () delay time in milliseconds; TTimeIntervalMicroSeconds32 interval following the initialization of the event is generated, Calculate in milliseconds; TCallback encapsulates a call-back method, TCallback (Tint (* Afunction) (TANY * APTR); TANY * APTR) Incoming a static method of a class, This method is incoming TANY * any object, returns the Tint type. Tany * APTR The class where the static method is located, can be NULL; threads are started by this method, and this static method is called at a certain time interval. 3. Stop thread, ITIMER-> Cancel (); instance: cperiodic * iperiodictimtimer; // Defines the activity object if (! Iperioditimer-> isactive ()) {iPeriodIictimer-> Start (10, 10, tcallback (cmap2container :: period, THIS))))); // Start thread and calls Static Period method} Tint CMap2Container :: Period (Tany * Aptr) // Specific PERIOD method {((cmap2container *) APTR) -> doperiodtask (); // Returning a value of True Indicates The Callback Should Be Done Again Return True;} Void CMap2Container :: DOPERIDTASK () {ItPoint.ix = ix ; itPoint.iy = IY ; DrawNow (); // Call the DRAW method, but not directly with DRAW / / Cwindowgc & gc = systemgc (); // gc.activate (* drawableWindow ()); // updatescreen (); // gc.deactivate (); // or this method redraw} void cmap2container :: updatescreen () Const {CWINDOWGC & GC = systemgc (); gc.bitblt (TPOINT (0, 0), IMAP); GC.Bitbltmasked (Itpoint, Iball, TRECT (TPOINT (0, 0), Iball-> SizeInpixels), Iballmask, ETRUE } Void draw () {updatescreen ();

转载请注明原文地址:https://www.9cbs.com/read-64584.html

New Post(0)