Sorry, but StrIToA use looks rather strange. You supply numUnitsStr as the first argument, but its value is unpredicatble (unless there is an extra code you ripped off). It may result in any weird thing.
Michael -----Original Message----- From: Sean McMains [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 28 November 2001 7:48 AM To: Palm Developer Forum Subject: FrmGetObjectIndex causes "Bad window" error Hi folks, Does anyone know why calling FrmGetObjectIndex would cause POSE to throw up an error dialog indicating "window.c, line:3826, Bad window"? It's happening in the following utility function, which I'm using from other places as well. As far as I can tell, the parameters are all ok, but there must be something I'm missing. :-P Here's the routine: static FieldPtr SetFieldTextFromHandle(UInt16 fieldID, MemHandle txtH, FormPtr frm, Boolean redraw) { MemHandle oldTxtH; FieldPtr fldP; UInt16 temp; // get the field and the field's current text handle. temp = FrmGetObjectIndex(frm, fieldID); // ERROR HAPPENS HERE fldP = FrmGetObjectPtr(frm, temp); ErrNonFatalDisplayIf(!fldP, "missing field"); oldTxtH = FldGetTextHandle(fldP); // set the field's text to the new text. FldSetTextHandle(fldP, txtH); if ( redraw ) FldDrawField(fldP); // free the handle AFTER we call FldSetTextHandle(). if (oldTxtH) MemHandleFree(oldTxtH); return fldP; } And here's where I'm calling it from: static void EditReminderDateFormInit(FormPtr frmP) { Reminder r; MemHandle h; Char *numUnitsStr; // Get Record from DB h = DmQueryRecord( gDB, gCurrentRecord - 1 ); UnpackReminder( &r, MemHandleLock( h ) ); // put text into field StrIToA( numUnitsStr, r.numUnits ); // it's stored as an Integer, so we convert it to string for the field gEditNumUnitsTextHandle = MemHandleNew( StrLen( numUnitsStr ) + 1 ); if ( !gEditNumUnitsTextHandle ) return; StrCopy( MemHandleLock( gEditNumUnitsTextHandle ), numUnitsStr ); MemHandleUnlock( gEditNumUnitsTextHandle ); // Point text fields to text handles SetFieldTextFromHandle( EditReminderDateNumUnitsField, gEditNumUnitsTextHandle, frmP, false ); } Thanks in advance for any help! I've been staring at this for a while, and it's just got me stymied. Sean -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
