home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / muzsrc1.zip / MENU.CPP < prev    next >
C/C++ Source or Header  |  1992-07-22  |  5KB  |  136 lines

  1. // **********************************************
  2. // File: MENU.CPP
  3. // Menu management module
  4.  
  5. #include "muzika.h"
  6. #include "menu.h"
  7.  
  8. HMENU hMainMenu;                  // The main menu handle
  9.  
  10. // **********************************************
  11. // ProcessMenu responds to a menu selection, which the user makes,
  12. // calling the appropriate functions accordingly.
  13.  
  14. BOOL ProcessMenu(WORD item)
  15. {
  16.   FARPROC lpDialog;
  17.  
  18.   switch (item) {
  19.     case M_FILE_NEW:
  20.       // The user selected "File/New...":
  21.       // create the relevant dialog box
  22.       if (!AskSave())
  23.         return TRUE;
  24.       lpDialog = MakeProcInstance((FARPROC) DialogNew, hInst);
  25.       DialogBox(hInst, "D_FILENEW", hMainWnd, lpDialog);
  26.       FreeProcInstance(lpDialog);
  27.       return TRUE;
  28.  
  29.     case M_FILE_OPEN:
  30.       // The user selected "File/Open...":
  31.       // create the relevant dialog box
  32.       lpDialog = MakeProcInstance((FARPROC) DialogOpen, hInst);
  33.       DialogBox(hInst, "D_FILEOPEN", hMainWnd, lpDialog);
  34.       FreeProcInstance(lpDialog);
  35.       return TRUE;
  36.  
  37.     case M_FILE_SAVE:
  38.       // The user selected "File/Save":
  39.       // call the Save function in FILE.CPP
  40.       Save();
  41.       return TRUE;
  42.  
  43.     case M_FILE_SAVEAS:
  44.       // The user selected "File/Save As...":
  45.       // create the relevant dialog box
  46.       lpDialog = MakeProcInstance((FARPROC) DialogSaveAs, hInst);
  47.       DialogBox(hInst, "D_FILESAVEAS", hMainWnd, lpDialog);
  48.       FreeProcInstance(lpDialog);
  49.       return TRUE;
  50.  
  51.     case M_FILE_CREATEMIDI:
  52.       // The user selected "File/Create MIDI...":
  53.       // create the relevant dialog box
  54.       lpDialog = MakeProcInstance((FARPROC) DialogCreateMIDI, hInst);
  55.       DialogBox(hInst, "D_FILECREATEMIDI", hMainWnd, lpDialog);
  56.       FreeProcInstance(lpDialog);
  57.       return TRUE;
  58.  
  59.     case M_PRINT:
  60.       // The user selected "Print":
  61.       // call the PrintEditWindow function in PRINT.CPP
  62.       PrintEditWindow();
  63.       return TRUE;
  64.  
  65.     case M_LAYOUT_PARTS:
  66.       // The user selected "Layout/Parts...":
  67.       // create the relevant dialog box
  68.       lpDialog = MakeProcInstance((FARPROC) DialogParts, hInst);
  69.       DialogBox(hInst, "D_LAYOUTPARTS", hMainWnd, lpDialog);
  70.       FreeProcInstance(lpDialog);
  71.       return TRUE;
  72.  
  73.     case M_LAYOUT_PAGE:
  74.       // The user selected "Layout/Page...":
  75.       // create the relevant dialog box
  76.       lpDialog = MakeProcInstance((FARPROC) DialogPage, hInst);
  77.       DialogBox(hInst, "D_LAYOUTPAGE", hMainWnd, lpDialog);
  78.       FreeProcInstance(lpDialog);
  79.       return TRUE;
  80.  
  81.     case M_LAYOUT_REFORMAT:
  82.       // The user selected "Layout/Reformat":
  83.       // call the FormatEntirePart function in FORMAT.CPP,
  84.       if (!scoreDisplay)
  85.         FormatEntirePart();
  86.       return TRUE;
  87.  
  88.     case M_SYMBOLS_NOTES:
  89.     case M_SYMBOLS_KEYS:
  90.     case M_SYMBOLS_BEATS:
  91.     case M_SYMBOLS_BARS:
  92.     case M_SYMBOLS_LOUDNESS:
  93.     case M_SYMBOLS_TEXT:
  94.     case M_SYMBOLS_BLOCK:
  95.       // The user selected a symbols set:
  96.       // check the appropriate menu item and call the SelectSymbolSet
  97.       // function in SYMBOLS.CPP
  98.       CheckMenuItem(GetSubMenu(hMainMenu, M_SYMBOLS),
  99.         activeSymbolSet+M_SYMBOLS_NOTES-1, MF_UNCHECKED);
  100.       CheckMenuItem(GetSubMenu(hMainMenu, M_SYMBOLS),
  101.         item, MF_CHECKED);
  102.       SelectSymbolSet(item-M_SYMBOLS_NOTES+1);
  103.       return TRUE;
  104.  
  105.     case M_HELP_ABOUT:
  106.       // The user selected "Help/About...":
  107.       // create the relevant dialog box
  108.       lpDialog = MakeProcInstance((FARPROC) DialogAbout, hInst);
  109.       DialogBox(hInst, "D_ABOUT", hMainWnd, lpDialog);
  110.       FreeProcInstance(lpDialog);
  111.       return TRUE;
  112.   }
  113.  
  114.   return FALSE;
  115. }
  116.  
  117. // **********************************************
  118. // InitializeMenu enables (when enabled=TRUE) or grays out
  119. // (when enabled=FALSE) several menu items, which are not
  120. // relevant as long as no melody exists in the editor memory.
  121.  
  122. void InitializeMenu(BOOL enabled)
  123. {
  124.   EnableMenuItem(GetSubMenu(hMainMenu, M_FILE),
  125.     M_FILE_SAVE, enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
  126.   EnableMenuItem(GetSubMenu(hMainMenu, M_FILE),
  127.     M_FILE_SAVEAS, enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
  128.   EnableMenuItem(GetSubMenu(hMainMenu, M_FILE),
  129.     M_FILE_CREATEMIDI, enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
  130.   EnableMenuItem(hMainMenu, M_PRINT,
  131.     (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED) | MF_BYCOMMAND);
  132.   EnableMenuItem(hMainMenu, M_LAYOUT,
  133.     (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED) | MF_BYPOSITION);
  134.   DrawMenuBar(hMainWnd);
  135. }
  136.