My SaveDate routing writes one record into the
database but the actual form fields (code and notes)
and the bitmap are not saved with the record. Where
did I do wrong? Thanks much.

/* db record structure */
typedef struct{
 Char *code;
 Char *notes;
 BitmapType *signature;
}DBRec;

static void SaveData()
{
 WinHandle win;
 Err error;
 BitmapType *bmpP;
 RectangleType rect;
 MemHandle newrecH;
 DBRec  newrec;
 DBRec  *newrecP;
 UInt16 ind = dmMaxRecordIndex;
        
 rect.topLeft.x = C_X;
 rect.topLeft.y = C_Y;
 rect.extent.x = C_EX;
 rect.extent.y = C_EY;

 /* turn palm drawing to a bitmap */    
 bmpP = BmpCreate(C_EX, C_EY, 1, NULL, &error);
 if (bmpP) 
 {
  win = WinCreateBitmapWindow(bmpP, &error);
  if (win)
  {
   WinSetDrawWindow(win); //not sure if this is needed
   WinCopyRectangle(NULL,win,&rect,C_X,C_Y, winPaint);
  }
  WinDeleteWindow(win, false); //done with the window
                
  /* save data and bitmap to db */
  newrec.code = GetFieldText(MainCodeField);
  newrec.notes = GetFieldText(MainNotesField);
  newrec.signature = bmpP;
  
  newrecH = DmNewHandle(gDB, sizeof(newrec));
  newrecP = MemHandleLock(newrecH);
                
  DmWrite(newrecP, 0, &newrec, sizeof(newrec));
  MemHandleUnlock(newrecH);
  DmAttachRecord(gDB, &ind, newrecH, NULL);
 }
 BmpDelete(bmpP); //saved, no longer needed.
}

/* read text from text field */
Char* GetFieldText(UInt16 ID)
{
 FieldPtr pField = NULL;
 Char*    pText = NULL;

 if ((pField = (FieldPtr)GetObjectPtr(ID)) != NULL)
 {
   pText = FldGetTextPtr (pField);
 } 
 else
 {
   pText = NULL;
 }

 return (pText);
}


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to