(1) LstGetSelectionText returns a pointer, not a handle. Hence locking it
is not well advises.
(2) LstGetSelectionText may return NULL (0). You should check for that. It
will return NULL if (a) nothing is selected, OR (b) your list stuff doesn't
have or cannot find the text.
Why, one asks, could a list not be able to find its selected text??
Good question!
There are, in essence, two different types of lists. One has static text
for each item (this can be pre-defined in the list resource, or dynamically
assigned. In both cases the text block consists of concatenated, null
terminated strings). The other has no static text -- instead it uses a draw
callback to draw any text the programmer wishes for each item. To further
muddy the waters, this draw callback MAY return a pointer to text, in which
case LstGetSelectionText will use that returned pointer.
As you can readily see from the above remarks, lists are NOT the simplest of
Palm GUI objects. (Nor are they the most complicated -- that distinction
indubitably goes to tables!) By far the easiest way to implement them is to
use pre-defined (in the resource) text strings for the list. I recommend if
for just getting off the ground.
hope this helps
-bob mckenzie
-----Original Message-----
From: Todd Cary [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 9:56 AM
To: Palm Developer Forum
Subject: Re: Need some off-line help
Many thanks for your warm welcome. I do not have any experience with the
Palm OS, so please bear with me; hoever, I do have the "Programmer's Bible"
at me side.
I am trying to learn about the Popup List and as part of my "learning"
application, I have a List (ListVarietal - a list of varieties of wine :-)
!!). When a slection is made, I want to put up a Alert box to tell me what
was selected - just part of learning. Well, I am not sure how to handle the
strings - even after reading the "Bible". Now, some of my
Procedures/Functions are slightly different from "C" (I can read "C", but I
am not a proficient "C" programmer - Delphi instead). Below is my
Event handler, but everything goes South!! I get the message that I am
trying to access memory that should not be accessed. I understand this
(thanks to the "Bible"), but I do not know how to retrieve the Item and
convert it to text that can be put into the Alert (once I am comfortable
doing that, I will put it into an "Edit" field).
Many, many thanks for any help you can offer.........
Todd
++++
procedure PopuptriggerVariety_OnPopSelect(var Handled: Boolean; ControlID:
UInt16; ControlP: ControlType; ListID: UInt16; ListP: ListType; Selection:
Int16; PriorSelection: Int16);
var
Form: FormPtr;
List: ListPtr;
ListIndex: UInt16;
P: MemPtr;
ListText: PChar;
begin
FrmCustomAlert(AlertShow, 'Here I am!, '', '');
Form := FrmGetActiveForm;
//From here on I am lost!!!!
//The name of the List is ListVariety
ListIndex := FrmGetObjectIndex(Form, ListVariety);
List := FrmGetObjectPtr(Form, ListIndex);
P := LstGetSelectionText(List, Selection);
ListText := MemHandleLock(P);
MemHandleFree(P);
Handled := True;
end;
++++
--
Todd Cary
Ariste Software
[EMAIL PROTECTED]
Jim Schram wrote:
> At 7:24 AM -0700 2001/08/21, Todd Cary wrote:
> >I am looking for someone who can answer some Palm OS questions outside
> >of this forum. The reason I need the help off-line is because my
> >development environment is Pascal - not "C", so my questions would not
> >be appropriate to this forum.
>
> This forum is here to answer *any* Palm OS development related question,
regardless of the development tools used. Depending on the question, you
might get better answers in one of the more specific forums (either for that
tool or for that area of the Palm OS). But in any case, don't let that stop
you from asking! There is a very broad audience of engineering talent
lurking here. At the very least someone will be happy to tell you where to
go (for the answers, of course... for the answers... ;o)
>
> Regards,
>
> Jim Schram
> Palm Incorporated
> Partner Engineering
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/