home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15538 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.1 KB  |  65 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!batcomputer!munnari.oz.au!metro!extro.ucc.su.OZ.AU!willw
  3. From: willw@extro.ucc.su.OZ.AU (William Waring)
  4. Subject: Re: Listview Help
  5. Message-ID: <willw.721266521@extro.ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: Sydney University Computing Service, Sydney, NSW, Australia
  9. References: <1992Nov7.052219.26938@mnemosyne.cs.du.edu>
  10. Date: Sun, 8 Nov 1992 23:48:41 GMT
  11. Lines: 52
  12.  
  13. kmccoy@nyx.cs.du.edu (Kevin McCoy) writes:
  14.  
  15. >How do you read the line selected in a GadTools Listview Gadget?
  16.  
  17. Heres a little code segment...
  18.  
  19. ...
  20.  
  21. Class = Msg->Class;
  22. Code = Msg->Code;
  23. Iaddress = Msg->Code;
  24. ...
  25.  
  26. switch (Msg->Class)
  27. {
  28.     case IDCMP_GADGETUP :
  29.         gid = ((struct Gadget *)Iaddress)->GadgetID;
  30.         switch (gid)
  31.         {
  32.             case LIST_GADGET :
  33.             /*
  34.             **    LIST_GADGET is the GadgetID of the
  35.             **    ListView gadget. Now the line that
  36.             **    was selected is returned in Code.
  37.         }
  38.         break;
  39. }
  40.  
  41.     There you go, this tells you the position in the list of node that
  42. was select, if you want the actual node then you have to get it yourself.
  43. Depending on the way you build the list, there are sevral ways to do this
  44.  
  45. i) If you allocate the list at compile time (ie have a array of Nodes
  46. pointing to each other) then the node is just NodeArray[Code].
  47.  
  48. ii) If you Dynamically build the list using AllocMem/AddTail then you'll
  49. eed to shoot along the list, for 'Code' nodes using the Node->ln_Succ.
  50.  
  51. iii) Another way I thought of was to Dynmically allocate an Array, using
  52. ReallocMem, but this function seem to get a bit shirty after about 1000
  53. Nodes, the beauty about this method is you can still access *(List+Code) 
  54. directly, but adding/deleting is kinda funky....
  55.  
  56. <No doubt someone is gonna tell me I'm doing something wrong>
  57.  
  58. hope this helps you... 
  59.  
  60. ---
  61. * Will    Waring |            The X-Comm Development Team
  62.   Edward Lawford |              willw@extro.ucc.su.OZ.AU 
  63.   Michael Lorant |             9107957@chico.cs.su.OZ.AU
  64. ------------------------------------------------------------------------------
  65.