Hello All,
I'm trying to create a table and so far all well. But
for some reason only the first row is being drawn.
I've spent hours searching and looking at different
source code trying to see what I'm missing, but no
luck.
Hopefully someone in this forum can spot the error.
//-------- CODE -----------
//TABLE INITIALIZATION
void InitTable(FormPtr frm)
{
UInt16 i, rowsInTable;
TablePtr tbl;
tbl = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm,
TblViewProducts_vp));
rowsInTable = TblGetNumberOfRows(tbl);
for(i=0; i<rowsInTable; i++)
{
//set the cell styles
TblSetItemStyle(tbl, i, prodNameColumn,
customTableItem);
TblSetItemStyle(tbl, i, prodIdColumn,
customTableItem);
TblSetItemStyle(tbl, i, prodPriceColumn,
customTableItem);
TblSetRowUsable(tbl, i, true);// so it can be
clicked upon
TblSetRowID(tbl, i, i);
}
TblSetColumnUsable(tbl, prodNameColumn, true);
TblSetColumnUsable(tbl, prodIdColumn, true);
TblSetColumnUsable(tbl, prodPriceColumn, true);
TblSetCustomDrawProcedure(tbl, prodNameColumn,
CustomDrawProduct);
TblSetCustomDrawProcedure(tbl, prodIdColumn,
CustomDrawProduct);
TblSetCustomDrawProcedure(tbl, prodPriceColumn,
CustomDrawProduct);
}
//THE CUSTOM CALLBACK FUNCTION FOR DRAWING THE CELLS
void CustomDrawProduct(void * tbl, Int16 row, Int16
column, RectanglePtr bounds)
{
UInt16 recordNum, x, y;
ProductUnpacked pUnpacked;
ProductPacked *pPacked;
MemHandle recordH;
Char *price;
x = bounds->topLeft.x;
y = bounds->topLeft.y;
recordNum = TblGetRowID (tbl, row);
recordH = DmQueryRecord(g_db, recordNum);
pPacked = (ProductPacked *) MemHandleLock(recordH);
if (pPacked == NULL)
{
ErrNonFatalDisplay ("Record not found");
return;
}
UnpackProduct(&pUnpacked, pPacked);
switch(column)
{
case prodNameColumn:
WinDrawChars(pUnpacked.name,
StrLen(pUnpacked.name), x, y);
break;
case prodIdColumn:
WinDrawChars(pUnpacked.id, StrLen(pUnpacked.id),
x, y);
break;
case prodPriceColumn:
price = (Char
*)MemPtrNew(GetSize(pUnpacked.price));
StrIToA(price, pUnpacked.price);
WinDrawChars(price, StrLen(price), x, y);
MemPtrUnlock(price);
break;
}
MemHandleUnlock(recordH);
}
//------ END CODE --------------
Perhaps I should mention that I call InitTable()
before FrmDrawForm();
Any hints would very helpfull!
Michel.P
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/