home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 344_02 / windows.doc < prev    next >
Text File  |  1980-01-03  |  3KB  |  63 lines

  1.                              Menu Magic
  2.  
  3.                            By Paul Ammann
  4.  
  5.  
  6. Throughout the 80's, we have seen many revolutions, one of these being in
  7. software. Software has advanced perhaps even faster than hardware. Software
  8. techniques, once reserved for the "big" minis and mainframes, have now
  9. found their way down to the microcomputer.
  10.  
  11. One technique that has gained rapid acceptance and popularity involves
  12. placing program options within pull-down menus. These menus appear on the
  13. screen allowing you to make a selection, and then return the underlying
  14. screen back to its original state (graphics and all).
  15.  
  16. The program listing used in this article demonstrates this pull-down
  17. technique and how it can be added to a C program. You can modularize most
  18. of the code in this program into subroutines and merge them into your own,
  19. or simply take the program as presented here and expand upon it.
  20.  
  21. In "Menu Magic", I have set up 5 menus that you can pull down from a menu
  22. bar at the top of the screen. Use the left and right cursor keys to move
  23. from one menu window to the next. Each time one of these windows appears,
  24. the title of the current menu reverses colors.
  25.  
  26. The top item in the new menu being displayed also appears with inverse
  27. color, highlighting that option. To make another selection, use the up and
  28. down cursor keys to highlight a different option. Once your option is
  29. highlighted, press [ENTER].
  30.  
  31. Only one menu has "logic" actively connected to it. This is the EXIT menu,
  32. which provides two options - REDO and EXIT. As you pull this menu down, the
  33. word REDO is highlighted. If you press [ENTER] now, the program re-runs
  34. itself. If you select EXIT, the program comes to an end.
  35.  
  36.  
  37. Menu Minuets
  38.  
  39. You can use "Menu Magic" to experiment with your own menus. You can alter
  40. the titles, the options within the menu, the number of options, and the
  41. width of the menu window. All these changes are possible with simple
  42. modifications to the data statements. The routine accepts data for up to
  43. 10 options per window, each option name can be up to 20 characters wide.
  44. For larger titles, you need to make some minor modifications to expand
  45. the INV.HEAD array, which contains the inverse image of the title.
  46.  
  47. The data for the menus in this example are contained in the
  48. INITIALIZATION_ROUTINE. Each group of data specifies one menu window. The
  49. first group specifies the ITEM window. The first data in the group is the
  50. word ITEM - the title of the menu. The program is currently set up to
  51. handle 4 characteres in the title.
  52.  
  53. The next two numeric values specify the X and Y coordinates of the
  54. upper-left corner of the menu; in this case X = 5, Y = 3. The second set
  55. of numeric values specify the width of the menu window in characters, and
  56. the number of options in the window; in this case WIDTH = 11, OPTIONS = 3.
  57.  
  58. The rest of the data in the first gorup contains the text of the options.
  59. Take care that the text is not longer than the width of the window, or
  60. it will be chopped off in the resulting display. A total 10 parameter
  61. positions for the window options can be in the data statements. Unused data
  62. positions should be left blank. Just remember the number of data positions
  63. in a window will be equal to the number of options.