And the author chimes in ;)
Tables are tricky, even when you're basing your work off a working example.
It seems you are trying to build a table with 5 rows and three columns
[checkbox] [text] [text]
You set the middle column to use the PatientBlock() fn to load the static
text in the patnames[] array into the table.
You don't provide any means of preloading the third column text fields, nor
do you set any of the checkboxes.
What you're missing (from the example) is:
A) Don't call TblSetLoadDataProcedure(tableP, 1, PatientBlock) more than
once... you have it in a loop, calling it for each row in the table. Just
once does just fine.
B) Make sure you've drawn the form *before* and *after* you call
MainFormInit() -- probably in your form event handler, as in:
frmOpenEvent:
frm = FrmGetActiveForm();
FrmDrawForm(frm);
MainFormInit();
FrmDrawForm(frm);
handled = true;
break;
C) After calling MainFormInit() redraw the form by calling
FrmDrawForm(frm); -- that will end up calling your PatientBlock() fn for
each row, to load the patient names into the middle column and draw the
table
D) consider adding another column load procedure (like the
DescriptionBlock() fn in the example) to initialize the other text field in
the table, if you want more control over its size/behavior.
- John Schettino
Palm OS Programming for Dummies: http://schettino.tripod.com
-----Original Message-----
From: Dave Lippincott [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 03, 2000 6:19 AM
To: Palm Developer Forum
Subject: Re: Table question
I don't see were you
1) use TblSetRowUsable
2) mark any of the rows invalid so they will get a draw message
or 2b) mark the table invalid
3) redraw the table
-----Original Message-----
From: Jaeha Lee <[EMAIL PROTECTED]>
To: Palm Developer Forum <[EMAIL PROTECTED]>
Date: Monday, April 03, 2000 8:04 AM
Subject: Table question
Hi,
I'm just starting Palm programming, and trying to implement a table with a
list of patient
I know this is not the good way to asking, but I have no iead what's wrong
in my code.
I just fallowing what "Palm programming for Dummies" told.
Could you kindly have a look at the code and tell me what I am missing ?
------------------------------------------------------------------
CharPtr patnames[] = {"Lein", "Craimmer", "Gorgey", "Sienfield", "Jerry"};
VoidHand PatientHandles = 0;
static Err PatientBlock (VoidPtr table, Word row, Word column,
Boolean editable, VoidHand *dataH, WordPtr dataOffset,
WordPtr dataSize, FieldPtr fld)
{
FieldAttrType attr;
CharPtr p;
VoidHand *handles;
FldGetAttributes(fld, &attr);
attr.editable = 0;
attr.underlined = 0;
attr.justification = rightAlign;
FldSetAttributes(fld, &attr);
if (!PatientHandles) {
ULong numBytes = TblGetNumberOfRows(table) * sizeof(Handle);
PatientHandles = MemHandleNew(numBytes);
handles = MemHandleLock(PatientHandles);
MemSet(handles, numBytes, 0);
MemHandleUnlock(PatientHandles);
}
handles = MemHandleLock(PatientHandles);
if (!handles[row]) {
handles[row] = MemHandleNew(StrLen(patnames[row])+1);
p = MemHandleLock(handles[row]);
StrCopy(p, patnames[row]);
MemHandleUnlock(handles[row]);
}
*dataH = handles[row];
*dataSize = MemHandleSize(*dataH);
*dataOffset = 0;
MemHandleUnlock(PatientHandles);
return 0;
}
static void MainFormInit(FormPtr frmP)
{
TablePtr tableP;
UInt rowstbl,i;
tableP = GetObjectPtr(MainPatientTableTable);
rowstbl = TblGetNumberOfRows(tableP);
for (i = 0; i < rowstbl; i++) {
TblSetItemStyle(tableP, i, 0, checkboxTableItem);
TblSetItemStyle(tableP, i, 1, textTableItem);
TblSetItemStyle(tableP, i, 2, textTableItem);
}
for (i = 0; i < 3; i++)
TblSetColumnUsable(tableP, i, true);
TblSetLoadDataProcedure(tableP, 1, PatientBlock);
}
-------------------------------------------------------------
I appreciate for any advice.
regards,
jaeha����?=������my����ru����?
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html