calling procedure from GUI using TIMER

Login to reply to this topic.
Mon, 2007-09-03 22:02
Joined: 2007-07-19
Forum posts: 11

Hello,

How can I call procedure HandleCommandL(TInt param) from GUI using  TIMER? I must call this procedure every specific period of time.

Slawek


Tue, 2007-09-04 02:22
Joined: 2007-04-29
Forum posts: 51
Re: calling procedure from GUI using TIMER

Hi,

I can catch your mind.

if you want to call a view::HandleCommandL, you can pass a pointor to this view into time object, then call the procedure via the pointor

Hope this answer is for your satisfaction.

Tue, 2007-09-04 10:12
Joined: 2004-11-29
Forum posts: 1197
Re: calling procedure from GUI using TIMER

And for timer, the quickest is probably to use CPeriodic, along these lines;

//construct
iTimer = CPeriodic::NewL(CActive::EPriorityStandard);

[...]
//a callback for timer event
LOCAL_C TInt Callback(TAny* aArg)
{
   CMyView* view = (CMyView*)aArg;
   view->HandleCommandL(...);
   return 0;
}
[...]
//to start it from a function within the view:
  iTimer->Start(KDelayToStart, KInterval, TCallBack(Callback,this));

//to stop:
 iTimer->Cancel();

Tue, 2007-09-04 21:16
Joined: 2007-07-19
Forum posts: 11
Re: calling procedure from GUI using TIMER


Thanks for this code, but maybe do you know why I receive errors associate with function TCallBack(..):

ERROR: no matching function for call to 'TCallBack::TCallBack (TInt (CClientBTAppUi:Smiling(TAny *), CCLientBTAppUi *)'
ERROR: candidates are: TCallBack::TCallBack(const TCallBack &) e32std.h

Wed, 2007-09-05 00:14
Joined: 2007-07-19
Forum posts: 11
Re: calling procedure from GUI using TIMER

LOCAL_C TInt Callback(TAny* aArg)
- this is wrong

it must be

TInt NAME_CLASS::Callback(TAny* aArg)

And everything will be all right:)

  • Login to reply to this topic.