Path: ns-mx!hobbes.physics.uiowa.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!UCONNVM.BITNET!STEIN From: STEIN@UCONNVM.BITNET (Alan Stein) Newsgroups: comp.sys.apple2 Subject: Problems With Menu Bar & DAs Message-ID: <9201051831.AA20932@apple.com> Date: 5 Jan 92 18:19:41 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 309 I've been having problems with menu bars in a program I've been writing. One of the big problems, which I have a feeling may be connected to other problems, is that the menu bar doesn't include the DAs. I've tried to isolate the problem by eliminating every part of the program but writing the menu bar and quitting the program, and also eliminated the use of the resource manager. I came up with the following skeleton, which I can't find anything wrong with except for the fact that the DAs still don't appear under the Apple Menu. I can't figure out anything I've done wrong here, and I'm wondering whether there's a bug in either the NewMenu2 tool or Orca itself. #pragma keep "Tester" #include #include #include #include #include #include #include #include #define quitID 257 static int masterID; /* user ID passed by loader */ static long startStopAddr; static StartStopRecord startStopRec = /* GS/OS 5.0 1-stop load tools call */ { 0, /* flags must be zero */ 0x0080, /* 640 mode */ 0, /* output: res file ID */ 0L, /* output: dPageHandle */ 13, /* we'll start 11 tools */ 0x0001, 0x0300, /* xTool Locator */ 0x0002, 0x0300, /* xMemory Manager */ 0x0003, 0x0300, /* xMiscellaneous Tool */ 0x0004, 0x0300, /* xQuick Draw II */ 0x0005, 0x0300, /* xDesk Manager */ 0x0006, 0x0300, /* xEvent Manager */ 0x000E, 0x0300, /* xWindow Manager */ 0x0010, 0x0300, /* xControl Manager */ 0x000F, 0x0300, /* xMenu Manager */ 0x0014, 0x0100, /* xLineEdit Toolset */ 21,0x0100, /* xDialog Manager */ 0x0016, 0x0104, /* xScrap Manager */ 0x001B, 0x0204}; /* xFont Manager */ int done = FALSE; int myID; char dropmenutitle00[]="\p@"; char menu00itemtitle00[] ="\pAbout This Program"; MenuItemTemplate menu00item00 = { /* item template */ 0, /* version number */ 0x0100, /* item id number */ 0x00, /* primary shortcut character */ 0x00, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0040, /* flags */ (long)menu00itemtitle00 /* item title reference */}; MenuTemplate menu00 = { /* menu */ 0, /* version, must be 0 */ 0x0001, /* menu ID number */ 0x0028, /* menu flags */ (long)dropmenutitle00, /* title reference */ (long)&menu00item00, /* item reference*/ 0, /* nul terminator */ }; char dropmenutitle01[]="\p File "; char menu01itemtitle00[] ="\pClose"; MenuItemTemplate menu01item00 = { /* item template */ 0, /* version number */ 0x00FF, /* item id number */ 0x00, /* primary shortcut character */ 0x00, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0040, /* flags */ (long)menu01itemtitle00 /* item title reference */}; char menu01itemtitle01[] ="\pQuit"; MenuItemTemplate menu01item01 = { /* item template */ 0, /* version number */ 0x0101, /* item id number */ 0x71, /* primary shortcut character */ 0x51, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0000, /* flags */ (long)menu01itemtitle01 /* item title reference */}; MenuTemplate menu01 = { /* menu */ 0, /* version, must be 0 */ 0x0002, /* menu ID number */ 0x0008, /* menu flags */ (long)dropmenutitle01, /* title reference */ (long)&menu01item00, /* item reference*/ (long)&menu01item01, /* item reference*/ 0, /* nul terminator */ }; char dropmenutitle02[]="\p Edit "; char menu02itemtitle00[] ="\pUndo"; MenuItemTemplate menu02item00 = { /* item template */ 0, /* version number */ 0x00FA, /* item id number */ 0x7A, /* primary shortcut character */ 0x5A, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0040, /* flags */ (long)menu02itemtitle00 /* item title reference */}; char menu02itemtitle01[] ="\pCut"; MenuItemTemplate menu02item01 = { /* item template */ 0, /* version number */ 0x00FB, /* item id number */ 0x78, /* primary shortcut character */ 0x58, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0000, /* flags */ (long)menu02itemtitle01 /* item title reference */}; char menu02itemtitle02[] ="\pCopy"; MenuItemTemplate menu02item02 = { /* item template */ 0, /* version number */ 0x00FC, /* item id number */ 0x63, /* primary shortcut character */ 0x43, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0000, /* flags */ (long)menu02itemtitle02 /* item title reference */}; char menu02itemtitle03[] ="\pPaste"; MenuItemTemplate menu02item03 = { /* item template */ 0, /* version number */ 0x00FD, /* item id number */ 0x76, /* primary shortcut character */ 0x56, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0000, /* flags */ (long)menu02itemtitle03 /* item title reference */}; char menu02itemtitle04[] ="\pClear"; MenuItemTemplate menu02item04 = { /* item template */ 0, /* version number */ 0x00FE, /* item id number */ 0x00, /* primary shortcut character */ 0x00, /* alt. shortcut character */ 0x0000, /* mark character */ 0x0000, /* flags */ (long)menu02itemtitle04 /* item title reference */}; MenuTemplate menu02 = { /* menu */ 0, /* version, must be 0 */ 0x0003, /* menu ID number */ 0x0008, /* menu flags */ (long)dropmenutitle02, /* title reference */ (long)&menu02item00, /* item reference*/ (long)&menu02item01, /* item reference*/ (long)&menu02item02, /* item reference*/ (long)&menu02item03, /* item reference*/ (long)&menu02item04, /* item reference*/ 0, /* nul terminator */ }; MenuBarTemplate MenuBar ={ 0, /* version */ 0, /* flag, refs are pointers */ (long)&menu00, /* menu reference */ (long)&menu01, /* menu reference */ (long)&menu02, /* menu reference */ 0, /* nul terminator */ }; /*********************************************** * * DoQuit - Handle Quit command. * ***********************************************/ void DoQuit () { done = TRUE; /* set the done flag */ } /* DoQuit */ /*********************************************** * * HandleMenu - Handle menu selections, menu IDs * 256 ->. * ***********************************************/ void HandleMenu (long menuData) { int theItem; int menuNum; /* Menu item ID is in low-order word of the menuData parameter. */ /* Menu ID is in the high-order word of the parameter. */ theItem = menuData; menuNum = menuData >> 16; /* Dispatch the appropriate routine, based on menu item selected. */ switch (theItem) { case quitID: DoQuit (); break; } /* Unhighlight the menu they just pulled down. */ HiliteMenu (FALSE, menuNum); } /* HandleMenu */ /*********************************************** * * EventLoop - Get next event, then dispatch the * appropriate routine to handle it. * ***********************************************/ void EventLoop () { EventRecord taskRecord; /* used to communicate with TaskMaster */ int eventCode; /* returned by TaskMaster */ done = FALSE; taskRecord.wmTaskMask = 0x001FBFFF; while (!(done)) { /* Call TaskMaster to get next event we need to handle. */ eventCode = TaskMaster (0x076E, /* event mask = just about everything * &taskRecord); /* pointer to extended task record * if (eventCode == wInMenuBar) HandleMenu (taskRecord.wmTaskData); } /* while not done */ } /* EventLoop */ /*********************************************** * * InitMenus - Initialize the menu bar. * ***********************************************/ void InitMenus (void) { MenuBarRecHndl menubarhandle; menubarhandle = NewMenuBar2 (refIsPointer, (long) &MenuBar, (Pointer) NULL); SetSysBar (menubarhandle); SetMenuBar (NULL); FixAppleMenu (appleMenuID); FixMenuBar (); DrawMenuBar (); } /* InitMenus */ void Init () { /* Initialize all global variables. */ masterID = _ownerid; /* get user ID passed by loader */ myID = masterID | 0x0200; /* alter for our purposes, so we can do */ /* a simple DisposeAll at the end */ /* Start the tools we need: Use GS/OS 5.0 one-call startup mechanism. */ startStopAddr = StartUpTools (masterID, refIsPointer, &startStopRec); InitMenus (); InitCursor (); /* StartUpTools brings up the watch cursor */ /* so change it to the arrow */ } /* Init */ void ShutDown () { DisposeAll (myID); ShutDownTools (refIsPointer, startStopAddr); } /* ShutDown */ void main () { Init (); /* start tools, bring up menu bar */ EventLoop (); /* execute main event loop */ ShutDown (); /* unload tools */ } /* Main */ __________________________________________________________ | | | Alan H. Stein | stein@uconnvm.bitnet | | Department of Mathematics | stein@uconnvm.uconn.edu | | University of Connecticut | Compu$erve 71545,1500 | | 32 Hillside Avenue | GEnie ah.stein | | Waterbury, CT 06710 | SNET (203) 757-1231 | |__________________________________________________________|