I have been working with a very simple app to try and learn how Code
Warrior does thing. And here is something that I am having problems
with.
I started with a simple "Hello World" program that I got out of the
Palm OS Programming Bible. I thought that for practice, I'd just add a
button to the main form that would bring up another form.
So I used the constructor to creat a form called Other and put one
button on it. But now, when I press the button on the main form that
is supposed to call up the Other form, I get an error that says:
"Resource for app form 9100 not found"
For some reason ApplicationHandleEvent is never called when I call
the FrmGotoForm(). Any ideas? Below is the code:
//==========================================================
#include "helloRsc.h"
static Err StartApplication(void)
{
FrmGotoForm(MainForm);
return 0;
}
static void StopApplication(void)
{
}
static void SaySomething(UInt16 alertID)
{
FormType *form = FrmGetActiveForm();
FieldType *field;
MemHandle h;
field = FrmGetObjectPtr(form, FrmGetObjectIndex(form,
MainNameField));
h = FldGetTextHandle(field);
if (h) {
Char *s;
s = MemHandleLock((void *)h);
if (*s != '\0') {
FrmCustomAlert(alertID, s, NULL, NULL);
} else {
FrmCustomAlert(alertID, "whoever you are", NULL,
NULL);
}
MemHandleUnlock((void *)h);
} else {
FrmCustomAlert(alertID, "whoever you are", NULL, NULL);
}
}
static void ShowOtherForm(UInt16 formID)
{
FrmGotoForm(formID);
}
static Boolean MainMenuHandleEvent(UInt16 menuID)
{
Boolean handled = false;
FormType *form;
FieldType *field;
form = FrmGetActiveForm();
field = FrmGetObjectPtr(form,
FrmGetObjectIndex(form, MainNameField));
switch (menuID) {
case MainEditUndo:
FldUndo(field);
handled = true;
break;
case MainEditCut:
FldCut(field);
handled = true;
break;
case MainEditCopy:
FldCopy(field);
handled = true;
break;
case MainEditPaste:
FldPaste(field);
handled = true;
break;
case MainEditSelectAll:
FldSetSelection(field, 0,
FldGetTextLength(field));
handled = true;
break;
case MainEditKeyboard:
SysKeyboardDialog(kbdDefault);
handled = true;
break;
case MainEditGraffitiHelp:
SysGraffitiReferenceDialog(referenceDefault);
handled = true;
break;
case MainOptionsAboutHelloWorld:
FrmAlert(AboutAlert);
handled = true;
break;
default:
break;
}
return handled;
}
static Boolean MainFormHandleEvent(EventPtr event)
{
Boolean handled = false;
#ifdef __GNUC__
CALLBACK_PROLOGUE;
#endif
switch (event->eType) {
case frmOpenEvent:
{
FormType *form = FrmGetActiveForm();
FrmDrawForm(form);
FrmSetFocus(form, FrmGetObjectIndex(form,
MainNameField));
handled = true;
}
break;
case ctlSelectEvent:
switch (event->data.ctlSelect.controlID)
{
case MainHelloButton:
SaySomething(HelloAlert);
handled = true;
break;
case MainGoodbyeButton:
SaySomething(GoodbyeAlert);
handled = true;
break;
case MainOtherButton:
ShowOtherForm (OtherForm);
handled = true;
break;
default:
break;
}
break;
case menuEvent:
handled =
MainMenuHandleEvent(event->data.menu.itemID);
break;
default:
break;
}
#ifdef __GNUC__
CALLBACK_EPILOGUE;
#endif
return handled;
}
static Boolean OtherFormHandleEvent(EventPtr event)
{
Boolean handled = false;
switch (event->eType) {
case frmOpenEvent:
{
FormType *form = FrmGetActiveForm();
FrmDrawForm(form);
handled = true;
}
break;
case ctlSelectEvent:
switch (event->data.ctlSelect.controlID)
{
case OtherOFBButton:
FrmGotoForm(MainForm);
handled = true;
break;
default:
break;
}
break;
default:
break;
}
return handled;
}
static Boolean ApplicationHandleEvent(EventPtr event)
{
FormType *form;
UInt16 formID;
Boolean handled = false;
if (event->eType == frmLoadEvent)
{
formID = event->data.frmLoad.formID;
form = FrmInitForm(formID);
FrmSetActiveForm(form);
switch (formID) {
case MainForm:
FrmSetEventHandler(form, MainFormHandleEvent);
break;
case OtherForm:
FrmSetEventHandler(form, OtherFormHandleEvent);
break;
default:
break;
}
handled = true;
}
return handled;
}
static void EventLoop(void)
{
EventType event;
UInt16 error;
do {
EvtGetEvent(&event, evtWaitForever);
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! ApplicationHandleEvent(&event))
FrmDispatchEvent(&event);
} while (event.eType != appStopEvent);
}
UInt32 PilotMain(UInt16 launchCode, MemPtr cmdPBP,
UInt16 launchFlags)
{
Err err;
switch (launchCode) {
case sysAppLaunchCmdNormalLaunch:
if ((err = StartApplication()) == 0) {
EventLoop();
StopApplication();
}
break;
default:
break;
}
return err;
}
=====
-Cynon-
"A contract without a sword is only a piece of paper"
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/