I get an error "object not in form" when i use FrmReturnToForm. I am using
two forms, the main form and EnterDataForm
which enters data into a database from a a series of lists. When i try to
return to the main form from the EnterDataFrom
using EnterDataForm(MainForm) it returns an error. Bellow i have included
the Mainform event handler and the EnterDataFrom
event handler. The EnterDataForm() call is located in ctlSelectEvent of the
EnterDataFrom event handler. The InsertRecord
function works correctly and logs entries in my data base.
If i removve the code in the lstSelectEvent of the EnterDataFormHandleEvent
the error no longer appears?
Its probably a simple thing but i would greatly appreciate any feedback!!
static Boolean MainFormHandleEvent(EventType * eventP)
{
Boolean handled = false;
FormType * frmP;
ListType * list;
Char * text;
Char buf[20];
switch (eventP->eType)
{
case menuEvent:
handled = true;
break;
case frmOpenEvent:
frmP = FrmGetActiveForm();
FrmDrawForm(frmP);
handled = true;
break;
case frmUpdateEvent:
/*
* To do any custom drawing here, first call
* FrmDrawForm(), then do your drawing, and
* then set handled to true.
*/
break;
case ctlSelectEvent:
switch (eventP->data.ctlSelect.controlID)
{
case NewRecordMainEntry:
FrmPopupForm(RecordEntryForm);
handled = true;
break;
default:
break;
}
case lstSelectEvent:
list = GetObjectPtr(MainDisplayList);
text = LstGetSelectionText(list,LstGetSelection(list));
SetField(MainForm,DisplayListValueField,text);
FrmDrawForm(FrmGetFormPtr(MainForm));
handled = true;
break;
}
return handled;
}
static Boolean EnterDataFormHandleEvent(EventType * eventP)
{
Boolean handled = false;
Int16 SystolicValueA;
Int16 SystolicValueB;
Int16 DiastolicValueA;
Int16 DiastolicValueB;
Int16 PulseValueA;
Int16 PulseValueB;
ListType * list;
FormType * ggg;
Char * text;
Char buf[20];
switch (eventP->eType)
{
case frmOpenEvent:
FrmDrawForm(FrmGetFormPtr(RecordEntryForm));
handled = true;
break;
case ctlSelectEvent:
switch (eventP->data.ctlSelect.controlID)
{
case RecordEntryFormDetailsButton:
handled = true;
break;
case RecordEntryFormOkButton:
InsertRecord(DiastolicValue,SystolicValue,PulseValue);
FrmReturnToForm(MainForm); // problem?
handled = true;
break;
default:
break;
}
case lstSelectEvent:
DiastolicValue = 0;
SystolicValue = 0;
PulseValue = 0;
//Getting Systolic value from the SystolicEntryList
list = GetObjectPtr(SystolicEntryListA);
text = LstGetSelectionText(list,LstGetSelection(list));
SystolicValueA = StrAToI(text);
list = GetObjectPtr(SystolicEntryListB);
text = LstGetSelectionText(list,LstGetSelection(list));
SystolicValueB = StrAToI(text);
SystolicValue = SystolicValueA + SystolicValueB;
//Getting Diastolic value from the DiastolicEntryList
list = GetObjectPtr(DiastolicEntryListA);
text = LstGetSelectionText(list,LstGetSelection(list));
DiastolicValueA = StrAToI(text);
list = GetObjectPtr(DiastolicEntryListB);
text = LstGetSelectionText(list,LstGetSelection(list));
DiastolicValueB = StrAToI(text);
DiastolicValue = DiastolicValueA + DiastolicValueB;
//Getting the Pulse value from the
list = GetObjectPtr(PulseEntryListA);
text = LstGetSelectionText(list,LstGetSelection(list));
PulseValueA = StrAToI(text);
list = GetObjectPtr(PulseEntryListB);
text = LstGetSelectionText(list,LstGetSelection(list));
PulseValueB = StrAToI(text);
PulseValue = PulseValueA + PulseValueB;
//SetField(MainForm,DisplayListValueField,StrIToA(buf,SystolicValue));
handled = true;
break;
}
return handled;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/