#pragma nda NDAOpen NDAClose NDAAction NDAInit 30 0xffff "--Dict\\H**"#pragma lint -1#include #include #include #include #include #include #include #include #include #include #include #include "test.h"WindowPtr MyWindow;Word MyID;Word MyRID;Word RadioOn;void DrawWindow(void){ DrawControls(GetPort());}GrafPortPtr NDAOpen(void){ Pointer myPath; Word oldLevel; Word oldPrefs; Word oldRApp; LevelRecGS levelDCB; SysPrefsRecGS prefsDCB; Handle H; // load our resource. -- see TN.iigs #71 oldRApp = GetCurResourceApp(); ResourceStartUp(MyID); myPath = LGetPathname2(MyID, 1); levelDCB.pCount = 2; GetLevelGS(&levelDCB); oldLevel = levelDCB.level; levelDCB.level = 0; SetLevelGS(&levelDCB); prefsDCB.pCount = 1; GetSysPrefsGS(&prefsDCB); oldPrefs = prefsDCB.preferences; prefsDCB.preferences = (prefsDCB.preferences & 0x1fff) | 0x8000; SetSysPrefsGS(&prefsDCB); MyRID = OpenResourceFile(readEnable, NULL, myPath); // MyWindow = NewWindow2(NULL, 0, DrawWindow, NULL, refIsResource, WindTest, rWindParam1); SetSysWindow(MyWindow); ShowWindow(MyWindow); SelectWindow(MyWindow); RadioOn = true; // prefsDCB.preferences = oldPrefs; SetSysPrefsGS(&prefsDCB); levelDCB.level = oldLevel; SetLevelGS(&levelDCB); SetCurResourceApp(oldRApp); return MyWindow;}void NDAClose(void){ CloseWindow(MyWindow); MyWindow = NULL; CloseResourceFile(MyRID); ResourceShutDown();}void NDAInit(Word code){ if (code) { MyWindow = NULL; MyID = MMStartUp(); MyRID = 0; } else { // nothing to do. }}word NDAAction(void *param, int code){word eventCode;static EventRecord event = { 0 };static word counter = 0; if (code == runAction) { if (RadioOn) SetCtlValueByID(counter++, MyWindow, CtrlWait); return 0; } if (code == eventAction) { BlockMove((Pointer)param, (Pointer)&event, 16); event.wmTaskMask = 0x001FFFFF; eventCode = TaskMasterDA(0, &event); switch(eventCode) { case updateEvt: BeginUpdate(MyWindow); DrawWindow(); EndUpdate(MyWindow); break; case wInControl: { CtlRecHndl ctrlH = GetCtlHandleFromID(MyWindow, CtrlWait); switch (event.wmTaskData4) { case CtrlRadioOn: RadioOn = true; HiliteControl(noHilite, ctrlH); ShowControl(ctrlH); break; case CtrlRadioOff: RadioOn = false; HiliteControl(inactiveHilite, ctrlH); ShowControl(ctrlH); break; case CtrlRadioHide: RadioOn = false; HideControl(ctrlH); break; } // switch(event.wmTaskData4) } // case wInControl } // switch (eventCode) return 0; } // code == eventAction return 0;}