I'm trying to update a field on second form after selecting a list item on
the main form. Interesting thing is occurring: the field on the second
form is picking up the text from the name of the button on that same form,
rather than carrying over the text from the list on the main form.
In the debugger, I can see that the Char* variable (declared globally in a
.h file) picks up the text from the selected list item and hows it until
the second form does a FrmDrawForm.
At that point, the Char* variable picks up the name of the button on the
newly drawn form.
I am using FrmGotoForm's to move from the main form (where the list is) to
the second form (where the field is).
Here are snippets of the code. I would appreciate some clarification of
what I am doing wrong.
TIA.
<rb>
//------------------------------------------------------------------------------
From the main form's event handler:
case lstSelectEvent:
switch ( event->data.lstSelect.listID )
{
case lstMyList:
form = FrmGetActiveForm();
pList = FrmGetObjectPtr(form,
FrmGetObjectIndex(form, lstMyList));
// pText is the globally declared variable.
pText = LstGetSelectionText(pList,
event->data.lstSelect.selection);
FrmGotoForm(frmTwo);
handled = true;
break;
From the second form's event handler:
case frmOpenEvent:
form = FrmGetActiveForm();
FrmDrawForm(form);
SelectedTextFromListToRemoteField(pText); // in
utils.c (in project)
handled = true;
break;
Function SelectedTextFromListToRemoteField located in utils.c in project:
//--------------------------------------------------------------------
void SelectedTextFromListToRemoteField (Char *pText)
//--------------------------------------------------------------------
// Function checks for selected list item, gets the text associated
// with that item and puts it in a field on the same form.
//
// PARAMETER: Char *pText: global pointer to list selection text.
// RETURN: nothing
//--------------------------------------------------------------------
{
FormType *form; // Pointer to form.
FormType *remoteForm; // Pointer to form.
FieldType *pField; // Pointer to field.
MemHandle textH; // Text already in field.
Char *tempPtr; // Temporary pointer.
// Get pointers to objects needed.
form = FrmGetActiveForm();
pField = FrmGetObjectPtr(form, FrmGetObjectIndex(form,
fldSecondField));
// Get old text handle and check validity.
textH = FldGetTextHandle(pField);
if (textH != NULL)
{
MemHandleResize(textH,StrLen(pText) + 1);
}
else
textH = MemHandleNew(StrLen(pText) + 1);
// Lock handle, copy text, unlock handle.
tempPtr = MemHandleLock(textH);
StrCopy(tempPtr, pText);
MemHandleUnlock(textH);
// Set the field's new text and draw it.
FldSetTextHandle(pField, textH);
FldDrawField(pField);
return;
} // end SelectedTextFromListToField
//--------------------------------------------------------------------
<rb>
http://www.randybrown.net
</rb>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/