Posting events and commands

Login to reply to this topic.
Wed, 2005-06-15 14:14
Joined: 2005-01-31
Forum posts: 33
Hi,

Is there a way to post/send a command or even to my app programmatically?
I know I can call HandleCommandL() directly but is there a way to actually post a command to be handled by some UI command/event loop?

Basically, I need to send a command to my app as soon as it starts, so any other ideas are welcome as well.

Thanx
Yaron Tadmor

Wed, 2005-06-15 15:50
Joined: 2004-05-24
Forum posts: 56
Re: Posting events and commands
Hi,

You may define your own window server event and send it to app (it will be processed async.). Then in HandleWsEventL() you may call HandleCommandL or do whatever you want.

This shows how to send TWsEvent:
Code:
TWsEvent event;
TInt activeWGroup = iCoeEnv->WsSession().GetFocusWindowGroup();
//Set event type
event.SetType(EEventUser);
//Get pointer directly to event data (it's size determines by EWsEventDataSize)
TUint8*data =  event.EventData() const;
for(TInt i = 0; i < EWsEventDataSize; i++)
{
*data++ = i;
}
iCoeEnv->WsSession().SendEventToWindowGroup(activeWGroup,event); // or maybee SendEventToAllWindowGroups instead

and there is how should we handle it:

Code:
void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
{

if(aEvent.Type() == EEventUser)
{
TUint8* data = aEvent.EventData();
for(TInt i = 0; i <EWsEventDataSize; i++)
{
if(*data++ != i) return;
}

//TODO: add your code here

}

}

This is not exactly what you want to do, but hope this helps...
Thu, 2005-06-16 08:25
Joined: 2005-01-31
Forum posts: 33
Re: Posting events and commands
Hi,

thanx for the reply, I guess this will do.
By the way, isn't a command just another type of event? Meaning, can I send the command I need as a command event?

Yaron
Thu, 2005-06-16 09:15
Joined: 2004-05-24
Forum posts: 56
Re: Posting events and commands
Hi,

No, there is no such event type.  Maybee it's possible to post the command but there is no way to do it using SendEventToWindowGroup(). Maybee there is another way to do it

Regards.
  • Login to reply to this topic.