home *** CD-ROM | disk | FTP | other *** search
- #include <MacTypes.h>
- #include "QuickDraw.h"
- #include <WindowMgr.h>
- #include <MenuMgr.h>
- #include <EventMgr.h>
- #include "Skel defines.h"
- #include "Skel globals.h"
-
- #include <MemoryMgr.h>
- #include <ToolboxUtil.h>
- #include <EventMgr.h>
- #include <TextEdit.h>
- #include <Stdio.h>
-
-
- /*
- Handle a command given through a menu selection
- ############################ DoCommand ##############################
-
- We carry out the command indicated by mResult.
- If it was Quit, we return true, else false. Since the menu was
- highlighted by MenuSelect, we must finish by unhighlighting it
- to indicate we're done.
- */
- long docommand (mresult)
- long mresult;
-
-
- {
- long refnum;
- long themenu,
- theitem;
- char name[255];
- GrafPtr saveport; /* for saving current port in when opening
- a desk accessory */
- StringHandle astr; /* Handle for a utility string */
- long returns;
-
- returns = 0; /* assume Quit not selected */
- themenu = HiWord (mresult); /* get the menu selected */
- theitem = LoWord (mresult); /* ... and the Item of that menu */
- switch (themenu) {
- case 0:
- break; /* user made no selection; do nothing */
-
- case applemenu:
-
- if (theitem == 1) { /* get string, and tell about Skel */
-
- /*
- It's important not to pass Report a de-referenced
- Handle; if Report were in another segment, loading
- it could cause a memory compaction; the de-referenced
- Handle could become invalid. Watch out for this
- and similar nasties everywhere in your program.
- See the Memory Manager and the Segment Loader.
- */
- astr = GetString (aboutskelid);
-
- report (astr);
- }
- else { /* run a desk accessory; make sure port is
- preserved */
- GetPort (&saveport);
- GetItem (mymenus[applemenu], theitem, name);
- /* get name */
- refnum = OpenDeskAcc (name);/* run the desk accessory */
- SetPort (saveport);
- }
- break;
-
- case filemenu:
- switch (theitem) {
- case irattle: /* Rattle */
- astr = GetString (rattleid);
- report (astr);
- break;
- case ifrighten: /* Frighten */
- astr = GetString (frightenid);
- report (astr);
- break;
- case iquit:
- returns = 1;/* Quit */
-
- } /* fileMenu case */
-
- } /* menu case */
-
- HiliteMenu (0); /* turn off hilighting on the menu just
- used */
- return (returns);
- } /* DoCommand */
-
-