hi,
sorry to post this message again. i have tried to
change my coding according to what was mentioned below
but now it hinted me fatal alert: object not in form.
do you know what this error is due to?? is there any
ways to debug or track it?
here are the new codes:
static void submenu (char *cde, int counter){
FormPtr newForm;
EventType openEvent;
int MenuX=5, MenuY=20;
MemHandle oldTxtH;
char title[20],*msg2, msg[10];
MemPtr FieldPtr;
StrPrintF(title,"Remarks for %s", cde);
newForm = FrmNewForm(SubmenuForm, title, 0, 75, 160,
160, true, 0, 0, 0);
currentIndex=counter;
FrmSetActiveForm(newForm);
FrmSetEventHandler(newForm, SubmenuFormHandleEvent);
// create new field //
FldNewField ((VoidPtr) &newForm, SubmenuField, MenuX,
MenuY, 155, 50, 0, 100 , true, true, false, true,
leftAlign, true, false, false);
oldTxtH = FldGetTextHandle((FieldType *)
GetObjectPtr(SubmenuField));
if ( oldTxtH == NULL )
oldTxtH = MemHandleNew(StrLen(array[counter])+1);
FieldPtr = MemHandleLock(oldTxtH);
StrCopy((char *)FieldPtr, array[counter]);
MemHandleUnlock(oldTxtH);
FldSetTextHandle((FieldType *)
GetObjectPtr(SubmenuField),oldTxtH);
CtlNewControl ((VoidPtr) &newForm, SubmenuButton,
buttonCtl, "OK", MenuX+59, 70, 30, 10, stdFont , 0,
true);
openEvent.eType = frmOpenEvent;
openEvent.data.frmOpen.formID = SubmenuForm;
EvtAddEventToQueue (&openEvent);
}
thanks
junyan
> --- Junyan wrote:
> hi. i would like to know what does these 2 fatal
> alert means
> 1) chunk under-locked
You locked a handle, then you unlocked it, then you
unlocked it again.
You should not try to unlock it more times than you
lock it.
> 2) object not in form
You are referring to an object that isn't in the
form. (see below)
> are there anything wrong with this coding?
yes.
typedef char iSubmenu[100];
iSubmenu array[MAXSIZE];
FldNewField ((VoidPtr) &newForm, SubmenuField,
MenuX, MenuY, 155, 50, 0, 100 , true, true, false,
true, leftAlign, true, false, false);
fldptr=(FieldPtr)GetObjectPtr(SubmenuField);
If you are using the GetObjectPtr() provided by
CodeWarrior stationery, then you will see that it
returns a pointer to an object in the currently active
form. It is highly likely that &newForm is not the
same form. (BTW, the first parameter to FldNewField
must be a pointer to a pointer to a form. Is newForm
a pointer to a form?) Furthermore, the docs for
FldNewField() state that "the old form pointer value
is
not necessarily valid after this function returns."
So, if you want to get a pointer to an object on the
form to which you have just added a new field, you
have to use the new form pointer value returned by
this
function.
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/