demosxs@iitmax.IIT.EDU (Sisanouk Sopha) (05/09/90)
I have problem with the following code. I would like to change resource file how do i do it correctly? The resource appeared to be changed when i check by GetInfo from File menu. This code is embeded in the THINK C's *sample* CDEV. #include <DialogMgr.h> #include <cdev.h> struct sys_info:cdev{ void Init(); }; #define MY_ITEM 1 /* radio botton */ #define MY_ITEM2 2 /*statText initially set to "SAMPLE"*/ boolean Runnable() { return TRUE; } cdev *New() { return new(sys_info); } void sys_info::Init() { int type; Handle hdl, thehdl; Rect box; inherited::Init(); thehdl= GetResource('DITL',-4064); HLock(thehdl); if (ResError==0) { GetDItem(this->dp,MY_ITEM + this->lastItem,&type,&hdl,&box); SetCtlValue(hdl,!GetCtlValue(hdl)); /* no toggle observed when ran second time or more */ GetDItem(this->dp,MY_ITEM2 +this->lastItem,&type,&hdl,&box); SetIText(hdl,"/pHello world"); /* this text won't replace what previously in MY_ITEM2 but show on control panel*/ ChangedResource(thehdl); WriteResource(thehdl); } HUnlock(thehdl); return; } when i use ResEdit to check the resource file the resource data still remained the same. What did i do wrong? This is my first attempt to change resource file in prrogramming the Mac. I would like to save current setting of my CDEV into resource file how should i do it? What about with my own resource type? I greatly appreciate your help...