home *** CD-ROM | disk | FTP | other *** search
/ EDUCORP 8 / Educorp2Compilation.sit / educorp2 / Demos / Aztec Source Level Debugger / demo / datest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-21  |  1.6 KB  |  103 lines

  1. #include    <quickdraw.h>
  2. #include    <windows.h>
  3. #include    <serial.h>
  4. #include    <events.h>
  5. #include    <menus.h>
  6. #include    <desk.h>
  7. #include    <fonts.h>
  8. #include    <dialogs.h>
  9.  
  10. #define    appleMenu     99
  11. #define    fileMenu    256
  12.  
  13. #define    NMENUS    2
  14.  
  15. MenuHandle myMenus[NMENUS];
  16.  
  17. struct GrafPort *whichWindow;
  18. struct EventRecord myEvent;
  19.  
  20.  
  21. main()
  22. {
  23.     int code;
  24.  
  25.     InitGraf(&qd.thePort);
  26.     InitWindows();
  27.     InitFonts();
  28.     setupmenu();
  29.     InitDialogs(0L);
  30.     InitCursor();
  31.  
  32.     for (;;) {
  33.         SystemTask();
  34.         if (!GetNextEvent(everyEvent, &myEvent))
  35.             continue;
  36.         switch (myEvent.what) {
  37.             case mouseDown:
  38.                 code = FindWindow(&myEvent.where, &whichWindow);
  39.                 switch (code) {
  40.                 case inMenuBar:
  41.                     docommand(MenuSelect(&myEvent.where));
  42.                     break;
  43.                 case inSysWindow:
  44.                     SystemClick(&myEvent, whichWindow);
  45.                     break;
  46.                 }
  47.                 break;
  48.             case keyDown:
  49.                 dokey();
  50.                 break;
  51.         }
  52.     }
  53. }
  54.  
  55. setupmenu()
  56. {
  57.     int i;
  58.     InitMenus();
  59.     myMenus[0] = NewMenu(appleMenu, "\024");
  60.     AddResMenu(myMenus[0], 'DRVR');
  61.     myMenus[1] = NewMenu(fileMenu, "File");
  62.         AppendMenu(myMenus[1], "Quit/Q");
  63.     for (i=0;i<NMENUS;i++)
  64.         InsertMenu(myMenus[i], 0);
  65.  
  66.     DrawMenuBar();
  67. }
  68.  
  69. docommand(mResult)
  70. long mResult;
  71. {
  72.     int theItem, theMenu;
  73.     char name[40];
  74.  
  75.     theMenu = mResult >> 16;
  76.     theItem = mResult;
  77.     switch(theMenu) {
  78.     case appleMenu:
  79.             GetItem(myMenus[0], theItem, name);
  80.             OpenDeskAcc(name);
  81.         break;
  82.     case fileMenu:
  83.             exit(0);
  84.     }
  85.     HiliteMenu(0);
  86. }
  87.  
  88.  
  89. dokey()
  90. {
  91.     short ch;
  92.     long menuChoice;
  93.  
  94.     ch = (short )(myEvent.message & charCodeMask);
  95.  
  96.     if (myEvent.modifiers & cmdKey) {
  97.         if (myEvent.what != autoKey) {
  98.             menuChoice = MenuKey(ch);
  99.             docommand(menuChoice);
  100.         }
  101.     }
  102. }
  103.