I couldn't believe this was so hard to figure out.
PhoneNumberLookupCustom and PhoneNumberLookup are both pretty useless for
letting users select a number from the address book on the Treo 600 and
Treo 650 (do they work better in other devices?)
The function below returns a handle to a number which the user has
selected.
It works on the t600 and the t650 at least.
Thanks to the posts on this group for getting me there.
Enjoy!
//returns Handle to phone number string if one is selected
//returns NULL if no number selected
//caller is responsible for freeing handle.
//Author Rob Jonson - Thanks to LionScribe for the initial code
MemHandle SelectPhoneNumber(void)
{
DmSearchStateType stateInfo;
UInt16 cardNo;
LocalID dbID;
UInt32 result;
Err err;
UInt32 dbCreator = 'PAdd';
Boolean rv = false;
SysNotifyParamType params;
AddrLookupParamsType lookupParams;
Char lookupString[]="";
Char *textP = "Select Number",*addP = "Ok";
Char *resultStrP;
MemSet(¶ms, sizeof(params), 0);
MemSet(&lookupParams, sizeof(lookupParams), 0);
params.notifyType =addrAppNotificationHsLookup;//
addrAppNotificationCmdCallerID;
params.notifyDetailsP = &lookupParams;
lookupParams.pasteButtonText = addP;
lookupParams.title = textP;
lookupParams.field1 = addrLookupSortField;
lookupParams.field2 = addrLookupVoicePhones;
lookupParams.field2Optional = true;
lookupParams.userShouldInteract = true;
lookupParams.formatStringP = "^voicephone";
err = DmGetNextDatabaseByTypeCreator(true, &stateInfo,
sysFileTApplication,dbCreator, true, &cardNo, &dbID);
if (err)
{
dbCreator = 'addr';
err = DmGetNextDatabaseByTypeCreator(true, &stateInfo,
sysFileTApplication, dbCreator, true, &cardNo, &dbID);
}
ErrNonFatalDisplayIf(!dbID, "Could not find app");
if (dbID)
{
err = SysAppLaunch(cardNo, dbID, 0,
sysAppLaunchCmdNotify,(MemPtr)¶ms, &result);
ErrNonFatalDisplayIf(err, "Could not launch app");
}
return lookupParams.resultStringH;
}--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/