home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14774 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.4 KB

  1. Path: sparky!uunet!sun-barr!ames!agate!stanford.edu!rutgers!concert!duke!news.duke.edu!phy.duke.edu!mur
  2. From: mur@phy.duke.edu (Daniel Murphy)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: changing resources
  5. Keywords: resources
  6. Message-ID: <4993@news.duke.edu>
  7. Date: 31 Aug 92 13:21:25 GMT
  8. Sender: news@news.duke.edu
  9. Distribution: usa
  10. Lines: 28
  11. Nntp-Posting-Host: physics.phy.duke.edu
  12.  
  13.  
  14.     I am trying to update a resource from within my program, in particular 
  15. I am trying to change a CNTL type resource's control value.  This piece of 
  16. code doesn't work,
  17.  
  18.         value=GetCtlValue((ControlHandle)control);
  19.         SetCtlValue((ControlHandle)control,value);
  20.         ChangedResource(control);
  21.         WriteResource(control);
  22. while
  23.         value=GetCtlValue((ControlHandle)control);
  24.         SetCtlValue((ControlHandle)control,value);
  25.         theHandle=Get1Resource('CNTL',128);
  26.         memcpy(*theHandle + 8, &value, (size_t)2);
  27.         ChangedResource(theHandle);
  28.         WriteResource(theHandle);
  29.  
  30. does.  Here control and theHandle are both Handles to the same control
  31. resource.  (Control was set using a GetDItem call.)  Does control now point 
  32. to the structure and theHandle to the actual resource?  Obviously I'd rather 
  33. avoid having to count bytes for every different type of resource in order to
  34. change it.  Any advice would be appreciated.
  35.  
  36.                     Dan Murphy.
  37. -- 
  38.     Daniel Murphy                1-919-660-2522
  39.     Duke University Dept. of Physics    mur@phy.duke.edu
  40.     Durham, N.C.      27706            
  41.