PDA

View Full Version : Passing control to another applet (with an argument)


Morgan
04-01-2002, 10:38 AM
Hi,

I'd like to pass control from applet Foo to applet Bar. The catch being that I'd like to pass Bar a string argument. I thought about using ISHELL_SendEvent to pass a char* to Bar and then starting Bar using ISHELL_StartApplet. But I'm unsure about passing the char* -- is there any guarantee that it will be valid when Bar handles the event sent to it by Foo?

If anyone has any suggestions, they'd be most appreciated. Oh, and if what I want to do is truly brain dead or impossible it would be nice to hear about that also.

Thanks

Morgan
04-03-2002, 07:42 AM
Hopefully, it's OK to reply to my own posts.

Using the ISHELL_SendEvent technique seems to work fine -- at least in the emulator.

In Foo I have:
<code>
char* info = "important";

// Bar decides whether or not to activate itself
ISHELL_SendEvent(m_pIShell, AEECLSID_BAR, MY_USR_EVT, 0, (uint32)name );
</code>
and in Bar's event handler I have the following case statement (where "name" is a data member of Bar):
<code>
case MY_USR_EVT: {
// name is a data member of Bar
name = STRDUP((const char*)dwParam);

ISHELL_StartApplet(m_pIShell, AEECLSID_BAR);

return true;
}
</code>

Mahesh
04-11-2002, 06:09 PM
On a related note:

When sending an event from one application to the next, it is possible for the event to get dropped. This can happen in the following case:

Availabe heap = 60K; App A Mod size = 45K (resident app); App B Mod size = 45K.

If App A sends an event to App B, App B will not be able to be loaded at all and the event will not go to B.

Only if App A calls ISHELL_StartApplet() with App B's classId, will BREW try to suspend or stop the current app and load the new one. Just sending events will not cause the app that is sending the event to be suspended or stopped.

--Mahesh
BREW Support