moyman@ecn.purdue.edu (James M Moya) (08/07/90)
Still learning how to make a cdev: OK, I have a cdev running solid (It shows up in the Control Panel, it opens, it closes, etc..). I can display items and process "hitDev" messages on those items, no problemo. *Where* do I store the settings when the cdev is closed?? I guess this "place" is where I will also read *in* the settings when the cdev is opened?? I can think of a few things, but they seem rather rough. What is the "proper" way to do this...I am using LSC 4.0+... Mike Moya Engineering Computer Network Purdue University
stevec@Apple.COM (Steve Christensen) (08/08/90)
In article <1990Aug7.141452.25133@ecn.purdue.edu> James M Moya writes: >Still learning how to make a cdev: > >OK, I have a cdev running solid (It shows up in the Control Panel, it opens, >it closes, etc..). I can display items and process "hitDev" messages on those >items, no problemo. *Where* do I store the settings when the cdev is closed?? >I guess this "place" is where I will also read *in* the settings when the cdev >is opened?? I can think of a few things, but they seem rather rough. What is >the "proper" way to do this...I am using LSC 4.0+... Usually you store the settings within the cdev itself. You just need to make a configuration resource that has all the settings in it. Then you can get to each of the fields by setting up a structure that mirrors the resource. To get the settings you just do a GetResource ('CNFG',-4048) (for example), which will give you a handle to the previously-defined structure. To save the changes back out (assuming that hitting buttons modify fields in the resource), you do a ChangedResource() to mark the resource changed, then UpdateResFile() to update the resource map and write the changes back out. Be sure to check ResError() after these calls to make sure they were successful. Also, you should handle the case of no configuration resource and build a new one with default settings. NewHandle(sizeof(theResource)) will give you a block to store the default settings in, then AddResource() to add it to your cdev file, and finally UpdateResFile() to write it out and update everything. Simple, eh? steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________