Below is some simple code I've written to display data in a textTableItem.
This is just a "quick and dirty" so that I could display some data.
However, I'm a bit worried about the handles I'm creating...

If there is a new record being added or deleted from the database, this
function will be called when the table is redrawn.  Shouldn't I be freeing
these handles?  If so, does anyone have any suggestions, considering this is
a dynamic table.


static Err LoadDataFoo(VoidPtr table, Word row, Word column, Boolean
editable, VoidHand *dataH, WordPtr dataOffset, WordPtr dataSize, FieldPtr
fld)
{
     Char a[FOO_LENGTH];
     tblFoo theFoo;
     Handle txtH;

     UInt index = tblRecord;

     // Query Record
     VoidHand record = DmQueryRecord(gFooDB, index);

     // Lock the Record and unpack it
     tblPackedFooPtr p = MemHandleLock(record);
     UnpackFoo(&theFoo, p);

     // Unlock the record
     MemHandleUnlock(record);

     // Copy double to a string
     doubleToStr(a, theFoo.number, 1, FOO_LENGTH - 2);

     txtH = MemHandleNew(StrLen(a) + 1);
     StrCopy(MemHandleLock(txtH), a);

     *dataH = txtH;
     *dataOffset = 0;
     *dataSize = MemHandleSize(*dataH);

     return(0);
}

--

Tim Astle





-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to