home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!batcomputer!munnari.oz.au!metro!extro.ucc.su.OZ.AU!willw
- From: willw@extro.ucc.su.OZ.AU (William Waring)
- Subject: Re: Listview Help
- Message-ID: <willw.721266521@extro.ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: Sydney University Computing Service, Sydney, NSW, Australia
- References: <1992Nov7.052219.26938@mnemosyne.cs.du.edu>
- Date: Sun, 8 Nov 1992 23:48:41 GMT
- Lines: 52
-
- kmccoy@nyx.cs.du.edu (Kevin McCoy) writes:
-
- >How do you read the line selected in a GadTools Listview Gadget?
-
- Heres a little code segment...
-
- ...
-
- Class = Msg->Class;
- Code = Msg->Code;
- Iaddress = Msg->Code;
- ...
-
- switch (Msg->Class)
- {
- case IDCMP_GADGETUP :
- gid = ((struct Gadget *)Iaddress)->GadgetID;
- switch (gid)
- {
- case LIST_GADGET :
- /*
- ** LIST_GADGET is the GadgetID of the
- ** ListView gadget. Now the line that
- ** was selected is returned in Code.
- }
- break;
- }
-
- There you go, this tells you the position in the list of node that
- was select, if you want the actual node then you have to get it yourself.
- Depending on the way you build the list, there are sevral ways to do this
-
- i) If you allocate the list at compile time (ie have a array of Nodes
- pointing to each other) then the node is just NodeArray[Code].
-
- ii) If you Dynamically build the list using AllocMem/AddTail then you'll
- eed to shoot along the list, for 'Code' nodes using the Node->ln_Succ.
-
- iii) Another way I thought of was to Dynmically allocate an Array, using
- ReallocMem, but this function seem to get a bit shirty after about 1000
- Nodes, the beauty about this method is you can still access *(List+Code)
- directly, but adding/deleting is kinda funky....
-
- <No doubt someone is gonna tell me I'm doing something wrong>
-
- hope this helps you...
-
- ---
- * Will Waring | The X-Comm Development Team
- Edward Lawford | willw@extro.ucc.su.OZ.AU
- Michael Lorant | 9107957@chico.cs.su.OZ.AU
- ------------------------------------------------------------------------------
-