PALM开发教程-第九章 分类和查找 |
| 作者:palmheart 来源:palmheart.net 发布时间:2005-12-21 3:36:55 |
|
imeType ) ); // CH.5 Unlock the record MemHandleUnlock( hrecord ); // CH.5 Clear the busy bit and set the dirty bit DmReleaseRecord( contactsDB, cursor, true ); // CH.5 Increment the total record count numRecords++; // CH.5 Set the dirty bit isDirty = true; // Ch.9 Get the record attribute bits DmRecordInfo( contactsDB, cursor, &recAttrs, NULL, NULL ); // CH.9 Clear the category bits recAttrs &= ~dmRecAttrCategoryMask; // CH.9 Set the category to the appropriate category if( listCat == dmAllCategories ) recAttrs |= dmUnfiledCategory; else recAttrs |= listCat; // CH.9 Set the record attributes DmSetRecordInfo( contactsDB, cursor, &recAttrs, NULL ); // CH.5 We're done return; } // CH.5 A time saver: Gets object pointers based on their ID static VoidPtr getObject( FormPtr form, Word objectID ) { Word index; // CH.5 The object index // CH.5 Get the index index = FrmGetObjectIndex( form, objectID ); // CH.5 Return the pointer return( FrmGetObjectPtr( form, index ) ); } // CH.5 Gets the current database record and displays it // in the detail fields static void setFields( void ) { FormPtr form; // CH.5 The contact detail form CharPtr precord; // CH.6 A record pointer Word index; // CH.5 The object index UInt recAttrs; // CH.9 The record attribute bits Char catName[dmCategoryLength]; // CH.6 The category name // CH.5 Get the contact detail form pointer form = FrmGetActiveForm(); // CH.5 Get the current record hrecord = DmQueryRecord( contactsDB, cursor ); // CH.6 Initialize the date and time variable precord = MemHandleLock( hrecord ); MemMove( &dateTime, precord + DB_DATE_TIME_START, sizeof( dateTime ) ); // CH.6 Initialize the date control setDateTrigger(); // CH.6 Initialize the time control setTimeTrigger(); // CH.5 Set the text for the First Name field setText( getObject( form, ContactDetailFirstNameField ), precord + DB_FIRST_NAME_START ); // CH.5 Set the text for the Last Name field setText( getObject( form, ContactDetailLastNameField ), precord + DB_LAST_NAME_START ); // CH.5 Set the text for the Phone Number field setText( getObject( form, ContactDetailPhoneNumberField ), precord + DB_PHONE_NUMBER_START ); MemHandleUnlock( hrecord ); // CH.5 If the record is already dirty, it's new, so set focus if( isDirty ) { // CH.3 Get the index of our field index = FrmGetObjectIndex( form, ContactDetailFirstNameField ); // CH.3 Set the focus to the First Name field FrmSetFocus( form, index ); // CH.5 Set upper shift on GrfSetState( false, false, true ); } // CH.9 Get the record attributes DmRecordInfo( contactsDB, cursor, &recAttrs, NULL, NULL ); // CH.9 Get the category detailCat = recAttrs & dmRecAttrCategoryMask; // CH.9 Set the category popup trigger label CategoryGetName( contactsDB, detailCat, catName ); CategorySetTriggerLabel( getObject( form, ContactDetailCategoryPopupPopTrigger ), catName ); // CH.5 We're done return; } // CH.5 Puts any field changes in the record void getFields( void ) { FormPtr form; // CH.5 The contact detail form // CH.5 Get the contact detail form pointer form = FrmGetActiveForm(); // CH.5 Turn off focus FrmSetFocus( form, -1 ); // CH.5 If the record has been modified if( isDirty ) { CharPtr precord; // CH.5 Points to the DB record // CH.7 Detach the record from the database DmDetachRecord( contactsDB, cursor, &hrecord ); // CH.5 Lock the record precord = MemHandleLock( hrecord ); // CH.5 Get the text for the First Name field getText( getObject( form, ContactDetailFirstNameField ), precord, DB_FIRST_NAME_START ); // CH.5 Get the text for the Last Name field getText( getObject( form, ContactDetailLastNameField ), precord, DB_LAST_NAME_START ); // CH.5 Get the text for the Phone Number field getText( getObject( form, ContactDetailPhoneNumberField ), precord, DB_PHONE_NUMBER_START ); // CH.7 Find the proper position cursor = DmFindSortPosition( contactsDB, pre |
| [] [返回上一页] [打 印] |
|
文章评论 |
