sonenbli@oxy.edu (Andrew D. Sonenblick) (08/25/89)
Ok, I'm not into premature hair-loss, but that is what I'm headed for (as in yank, yank!) Yes, I have a problem with this simplest of DA's (code follows) It works properly--except whenever an application (including Finder) quits out from under it (it works fine under MultiFinder, of course). What happens is that my Mac just hangs! (watch cursor comes up, disk whirs a bit, then hangs forever--if I use Macsbug and issue an ES (ExitToShell) it returns to hanging!!!!) AND I CAN'T FIGURE OUT WHY THIS IS HAPPENING!! So I'm forced to ask the honorable and wise comp.sys for advice. ***** I implore you, if you would just peruse this code ****** and if you see anything wrong (or lacking!) in it, please drop me an eline! ***** Thanks much: Ando Moon. sonenbli@oxy.edu ****** #include <MacTypes.h> #include <EventMgr.h> #include <DeskMgr.h> #include <DeviceMgr.h> #include <QuickDraw.h> #include <WindowMgr.h> #include <DialogMgr.h> #include <MenuMgr.h> DCtlPtr dce; int already_open=0; WindowPtr myWindow; Boolean windowOpen = false; int DoOpen() { int x,y; MenuHandle appleMenu; Str255 theMenu; Rect windowRect; GrafPtr savedPort; dce->dCtlFlags |= dNeedLock | dNeedTime | dNeedGoodBye; /*no matter my dce->dCtlDelay = 0; flags, it if (!already_open) still seems {already_open=TRUE; to always windowOpen = true; HANG!!!*/ SetRect(&windowRect,50,50,300,250); SysBeep(8); myWindow=NewWindow(0,&windowRect,"\pTotal UnFunNess",true,0, (WindowPtr)-1,true,0); ((WindowPeek)myWindow)->windowKind=dce->dCtlRefNum; dce->dCtlWindow=(GrafPtr)myWindow; GetPort(&savedPort); SetPort(myWindow); MoveTo(20,20); DrawString("\pHi, this is a sample that"); MoveTo(20,45); DrawString("\pmakes mac hang after kiss!"); SetPort(savedPort); } } doClose() { int itemhit,x; MenuHandle appleMenu; Str255 theMenu; DisposeWindow(myWindow); dce->dCtlWindow0L; } main(p,d,n) cntrlParam * p; DCtlPtr d; int n; { Rect tRect; Str255 str; GrafPtr savedPort; if (d->dCtlStorage == 0) { if (n==0) { SysBeep(5); CloseDriver(d->dCtlRefNum); } return(0); } dce=d; switch (n) { case 0: DoOpen(); break; case 2: { switch (p->csCode) { case accEvent: case accCursor: break; case accRun: break; case accMenu: case accCopy: case accCut: case accPaste: case goodBye: case accClear: break; } } break; case 4: doClose(); break; } return 0; } Sorry about the odd spacing; it was just uploaded weirdly. Again, if you have any hints as to what the problem(s) may be, please reply. Thanks again. Ando Moon ------sonenbli@oxy.edu----------------------------------------------------------