home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / sclib31 / examples / menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-31  |  2.2 KB  |  72 lines

  1. #include <scl1.h>
  2. #include <scl1clor.h>
  3.  
  4. /* Shows the use of Menu, MouseMenu and MouseMenu2 */
  5.  
  6. struct MenuOpt Mainm[7]={/*Array of structures with 7 elements */
  7.       5,26,"Screen Related Functions    ",'S', /* First option */
  8.       7,26,"Keyboard Handling Functions ",'K', /* Second option */
  9.       9,26,"Mouse Handling Functions    ",'M', /* Third option */
  10.      11,26,"Program Flow Functions      ",'P', /* Fourth option */
  11.      13,26,"File Handling Functions     ",'F', /* Fifth option */
  12.      15,26,"Background and Miscellaneous",'B', /* Sixth option */
  13.      17,26,"Exit Demo                   ",'E', /* Seventh option */
  14.      };
  15.  
  16. main()
  17. {
  18. int Selection;
  19.  
  20. Cls(WHITE_BLACK,CLS_ALL);
  21. Box(WHITE_BLACK,1,3,24,18,55);             /* Box for menu */
  22. WriteScreen(WHITE_BLACK,3,38,"MENU");      /* Menu title */
  23.  
  24. /* Menu */
  25.  
  26. Selection=Menu(WHITE_BLACK,BLACK_WHITE,WHITE_BLACK+HIGHLIGHT,7,Mainm);
  27. Cls(WHITE_BLACK,CLS_ALL);
  28.  
  29. if(Selection > 0)
  30.      printf("You have selected option %i, press any key...\n",Selection);
  31. else
  32.      printf("You have pressed ESCAPE, press any key...\n");
  33.  
  34. GetKey();
  35. InitMouse(IM_SHOW);
  36.  
  37. /* MouseMenu */
  38.  
  39. Cls(WHITE_BLACK,CLS_ALL);
  40. Box(WHITE_BLACK,1,3,24,18,55);               /* Box for menu */
  41. WriteScreen(WHITE_BLACK,3,35,"MOUSE MENU");  /* Menu title */
  42.  
  43. Selection=MouseMenu(WHITE_BLACK,BLACK_WHITE,WHITE_BLACK+HIGHLIGHT,7,Mainm,24,55,3,18);
  44.  
  45. Cls(WHITE_BLACK,CLS_ALL);
  46. if(Selection > 0)
  47.      printf("You have selected option %i\n",Selection);
  48. else
  49.      printf("You have pressed ESCAPE or clicked the mouse outside the menu area.\n");
  50. WaitKeyMouse();
  51.  
  52. /* MouseMenu2 - with MouseMenu2 you can select the option that will be
  53.    active when the menu first appears (last parameter) */
  54.  
  55. Cls(WHITE_BLACK,CLS_ALL);
  56. Box(WHITE_BLACK,1,3,24,18,55);               /* Box for menu */
  57. WriteScreen(WHITE_BLACK,3,35,"MOUSE MENU2 ");  /* Menu title */
  58.  
  59. Selection=MouseMenu2(WHITE_BLACK,BLACK_WHITE,WHITE_BLACK+HIGHLIGHT,7,Mainm,24,55,3,18,3);
  60.  
  61. Cls(WHITE_BLACK,CLS_ALL);
  62. if(Selection > 0)
  63.      printf("You have selected option %i\n",Selection);
  64. else
  65.      printf("You have pressed ESCAPE or clicked the mouse outside the menu area.\n");
  66.  
  67. }
  68.  
  69.  
  70.  
  71.  
  72.