Hi,
I have TblSetCustomDrawProcedure (tableP, column0,
MyFormDrawRecord);
in my program. MyFormDrawRecord is the call back
function define as follows
static void MyFormDrawRecord(MemPtr tableP, Int16 row,
Int16 column, RectanglePtr bounds)
{
Int16 textLen, width;
Boolean fits;
UInt16 recordNum = 0;
FontID currFont;
MemHandle recordH;
Char recText[64];
Char tempstr[80];
SkinRec *p=NULL;
Err err = 0;
// Set the standard font. Save the current font.
// It is a Pilot convention to not destroy the
current font
// but to save and restore it.
currFont = FntSetFont (stdFont);
// Get the record number that corresponds to the
table item to draw.
// The record number is stored in the "intValue"
field of the item.
recordNum = TblGetItemInt ((TablePtr)tableP, row,
column); // PROBLEM HERE
recordH = DmGetRecord(MyRefDB, recordNum);// need
to release when done
p = (SkinRec *)MemHandleLock(recordH);
if (column == 0) {
StrPrintF(tempstr,"%2d.",recordNum + 1);
// Now draw the index of the record.
WinDrawChars(tempstr, 3, bounds->topLeft.x,
bounds->topLeft.y);
StrCopy(recText, p->skinDBName);
// Determine the length of text that will fit
within the bounds.
width = bounds->extent.x - 7;
textLen = StrLen(recText);
FntCharsInWidth(recText, &width, &textLen,
&fits);
if (!fits) {
WinDrawChars("...",3,bounds->topLeft.x +
bounds->extent.x - 7,bounds->topLeft.y);
}
// Now draw the text from the record.
WinDrawChars(recText, textLen,
bounds->topLeft.x+15, bounds->topLeft.y);
}
// Unlock memory
MemHandleUnlock(recordH);
// Release the record and mark it NOT dirty
DmReleaseRecord(MyRefDB, recordNum, false);
// Restore the font.
FntSetFont (currFont);
}
In my program I have a table which loads all the DB's
names created for this app at start up. User can
select any name and delete it from the table. Let's
say I have 4 records:
1- DB1 // row 0, colum 0
2- DB2 // row1, "
3- DB3 // row2, "
4- DB4 // row3, "
If I ever select the last record in this table -->
DB4, delete it, and the select any other records, for
instance, DB2, the the system calls the call back
function, and passes in row = 3, column = 0 which is
of DB4 (already deleted) into TblGetItemInt and
returns recordnum = 3. DmGetRecord fails because
record 3 is no long in the database. I am very
surprised as why it does not pass in row = 1, column =
0 for DB2 I just selected.
Since I don't have control over what the system passes
in for row and column to my call back function, I
don't know how to fix it.
I wonder how, where, and when it gets this data?
After I delete a record, I call a function to reload
the table, and also call TblRedrawTable. There is no
problem if I delete other records, and not the last
one, or after I delete the last one, go to another
form, then come back and select another record, then
everything works.
Has anyone seen this before? Any help or suggestions
you can pass along very much appreciated. Please help
me!
Thanks!
=====
Best regards,
Van Nguyen.
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/