>I used constructor to add a popup trigger to a form and I then dynamically
create a list that I connect to the popup trigger.
Since you're already creating the popup trigger in constructor, you might as
well create the list there too. This is how it's normally done. If you want to
change the list contents at runtime, keep using LstSetListChoices.
This may or may not "fix" your problem, but it at least will make it closer to
normal.
If you still have the problem, I highly recommend just using a debugger to see
what's causing the read error.
-Roger
"Chris Yourch" <[EMAIL PROTECTED]> on 12/14/99 02:30:43 PM
Please respond to [EMAIL PROTECTED]
Sent by: "Chris Yourch" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (Roger Flores/HQ/3Com)
Subject: LstNewList
Hi,
I am just getting started with the palm OS and am having some trouble
dynamically creating a list control that is connected to a popup trigger.
I used constructor to add a popup trigger to a form and I then dynamically
create a list that I connect to the popup trigger. I am getting the error
message "... just read directly from an unallocated chunk of memory". See
below for the code I am using.
Thanks,
Chris
-------------------------------------------------------
FormPtr m_pForm;
VoidHand m_hStrings;
Word eCredentialID = 101;
void CContactForm::OnOpenForm()
{
ListPtr trigger =
(ListPtr)GetObjectPtr(ContactIdentificationCredentialPopTrigger);
Word visibleItems = 3;
Err ret = LstNewList(&m_pForm, eCredentialID,
trigger->bounds.topLeft.x,
trigger->bounds.topLeft.y,
trigger->bounds.extent.x,
trigger->bounds.extent.y,
stdFont, visibleItems,
ContactIdentificationCredentialPopTrigger);
ListPtr list = (ListPtr)GetObjectPtr(eCredentialID);
CtlSetUsable((ControlPtr)list, false);
CharPtr pStrings = "PA\0MD\0RNP\0ME\0RN\0";
Word nStrCnt = 5;
m_hStrings = SysFormPointerArrayToStrings(pStrings, nStrCnt);
char **p = (char **)MemHandleLock(m_hStrings);
LstSetListChoices(list, p, nStrCnt);
}
void CContactForm::OnCloseForm()
{
ListPtr list = (ListPtr)GetObjectPtr(eCredentialID);
LstSetListChoices(list, NULL, 0);
MemHandleUnlock(m_hStrings);
MemHandleFree(m_hStrings);
m_hStrings = NULL;
}