This is how it's done:
if (RecInfoDirty) {
isPrivate =
CtlGetValue((ControlPtr)GetObjectPtr(Detail_Private_Checkbox));
if (isPrivate)
RecAttr |= dmRecAttrSecret;
else
RecAttr &= ~dmRecAttrSecret;
DmSetRecordInfo (PinDB, prefs.editPinNo, &RecAttr,
NULL);
}
This code assumes that you've got a checkbox (Detail_Private_Checkbox) that
is checked if the record is private. If you don't care about private
records, just omit the if (isPrivate) block. You've got to have the record
opened with write permissions. You need to release the record after you're
done updating the attributes.
When you open a record, you get the current category using something like:
DmRecordInfo (PinDB, prefs.editPinNo, &RecAttr, NULL, NULL);
recCategory = RecAttr & dmRecAttrCategoryMask;
// set the category trigger in the edit form to the record's
category
RecInfoDirty = false;
If the user edits the record and changes the category, update RecAttr:
(in the edit form event handler)
case ctlSelectEvent: // A control button was pressed and released.
switch (eventP->data.ctlSelect.controlID) {
case Detail_CategoryPopTrigger: {
Char detailCatName[dmCategoryLength];
Boolean categoryEdited;
Word recCategory;
Word selectedCat;
ListPtr lp
=(ListPtr)GetObjectPtr(Detail_CategoriesList);
// Process the category popup list.
recCategory = (RecAttr &
dmRecAttrCategoryMask);
selectedCat = recCategory;
CategoryGetName(PinDB, recCategory,
detailCatName);
frmP = FrmGetActiveForm();
categoryEdited = CategorySelect (PinDB,
frmP,
Detail_CategoryPopTrigger,
Detail_CategoriesList, false,
&selectedCat, detailCatName, 1, 0);
if (categoryEdited || (selectedCat !=
recCategory)) {
RecInfoDirty = true; // Force save
if (categoryEdited &&
(prefs.categoryView == recCategory))
prefs.categoryView =
selectedCat; // change overview category
// save record category
RecAttr &= ~dmRecAttrCategoryMask;
RecAttr |= selectedCat;
}
}
handled = true;
break;
This code is from Chapter 13 of my book, Palm OS Programming For Dummies.
==-
John Schettino author of
Palm OS Programming For Dummies, http://schettino.tripod.com
-----Original Message-----
From: Brian O'Grady [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 30, 1999 8:34 AM
To: [EMAIL PROTECTED]
Subject: Record Info / Categories
Hello,
Can someone please explain to me how to set a records category? I
believe I have to use DmSetRecordInfo() and the category number goes into
the attribute but isn't the attribute also used to set the record to secret?
Any assistance is always appreciated. Thank You.
Brian O'Grady