Still no progress on solving my problem - I'll post a code snippet here and
hope someone can see what I'm doing wrong.
Each element of the gLabels structure array has an unlocked handle to
20-odd bytes of storage.
The two-column table works fine until the user selects/highlights a text
cell for the SECOND time (the program does not take the selection until the
user presses an "OK" button). Then I get an "Invalid Size" error (running
IIIc debug ROM on Emulator) and things go downhill (reallocation error).
I've tried all manner of fixes for this - trying to understand what is
going on - but to no avail. The field is set to non-editable, so there
should be no change being made to the contents (?!?)
Any thoughts?
Erik Blake
//***************************************************************************
//***************************************************************************
static Boolean MainFormEventHandler(EventPtr event)
{
Boolean handled = false;
FormPtr pForm;
UInt16 i, row, column;
TablePtr pTable;
Char s[20];
FieldPtr pField;
pForm = FrmGetActiveForm();
switch (event->eType)
{
case frmOpenEvent:
vLoadHolesTable(0, 10);
FrmDrawForm(pForm);
handled = true;
break;
case frmCloseEvent:
handled = false; // fall through to
Erase/Delete form
break;
case tblSelectEvent:
pTable = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
tableID_DisplayHoles));
pField = TblGetCurrentField(pTable);
if (pField)
FldSetSelection(pField, 0, FldGetTextLength(pField));
handled = true;
break;
case ctlSelectEvent:
pTable = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
tableID_DisplayHoles));
switch (event->data.ctlEnter.controlID)
{
case buttonID_OK:
TblGetSelection(pTable, &row, &column);
StrPrintF(s, "OK: %d:%d", row, column);
vDebug(s, " ", " ");
handled = true;
break;
}
break;
}
return(handled);
}
void vLoadHolesTable(UInt16 topRowIndex, UInt16 nHoles)
{
FormPtr pForm;
TablePtr pTable;
UInt16 i, index;
pForm = FrmGetActiveForm();
pTable = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
tableID_DisplayHoles));
index = 0;
TblSetColumnUsable(pTable, 0, true);
TblSetColumnUsable(pTable, 1, true);
for (i = 0; i < tableRows; i++)
{
TblSetItemStyle(pTable, i, 0, textTableItem);
TblSetItemStyle(pTable, i, 1, numericTableItem);
TblSetRowSelectable(pTable, i, true);
TblSetItemFont(pTable, i, 0, 1);
TblSetItemInt(pTable, i, 1, i);
TblMarkRowInvalid(pTable, i);
TblSetRowUsable(pTable, i, true);
TblSetRowStaticHeight(pTable, i, true);
index++;
}
TblSetLoadDataProcedure(pTable, 0, HoleViewLoadDataFunc);
TblSetSaveDataProcedure(pTable, 0, HoleViewSaveDataFunc);
}
Err HoleViewLoadDataFunc(void *pTable, Int16 row, Int16 column,
Boolean editable, MemHandle *dataH, Int16 *dataOffset, Int16 *dataSize,
FieldPtr pFld)
{
Char tBuf[100], *cBuf;
UInt16 i;
FieldAttrType attr;
Err err;
// load text
cBuf = (Char *)MemHandleLock(gLabels[row].h);
StrPrintF(cBuf, "LINE (%d)", row);
StrPrintF(tBuf, "Load %d:%d|%ld %s", row, column, gLabels[row].h, cBuf);
TRACE(true, tBuf);
MemHandleUnlock(gLabels[row].h);
*dataH = gLabels[row].h;
*dataOffset = 0;
*dataSize = tableLableLength;
// set field attributes
if (pFld)
{
FldGetAttributes(pFld, &attr);
attr.singleLine = true;
attr.underlined = noUnderline;
attr.editable = false;
attr.dynamicSize = false;
FldSetAttributes(pFld, &attr);
}
else
TRACE(true, "Ptr NULL");
// mark row invalid
// TblMarkRowInvalid(pTable, row);
return(0);
}
Boolean HoleViewSaveDataFunc(void *pTable, Int16 row, Int16 column)
{
Char s[40];
StrPrintF(s, "Save %d:%d", row, column);
TRACE(true, s);
// TblMarkRowInvalid(pTable, row);
// TblRedrawTable(pTable);
return(false);
}
-------------------------------------------------------------------
Icefield Tools Corporation tel: (867) 633-4264
3C Glacier Road fax: (867) 633-4217
Whitehorse, Yukon CANADA e-mail: [EMAIL PROTECTED]
Y1A 5S7 internet: http://www.icefieldtools.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/