C语言课程设计案例--菜单设计(国外英文资料)
C语言课程设计案例--菜单设计(国外英文资料)
The debugging environment is TC2.0 or 3.0. Running this program requires several header files from the tc. It is recommended to modify the include directory entry in the options menu to the directory under the tc's include (see chapter 1 for details). Or copy the source program to the tc directory.
# include < conio. H >
# include < DOS. H >
# include < graphics. H >
# include < stdio, h >
# include < stdlib. H >
/ * define some constant * /
# define NO 0
1 # define YES
# define NONE - 1
# define MAX_MENU 7 / * according to the situation changes the maximum number of items that can be displayed in the menu
/ * global parameter * /
Int X, Y;
Int Selection;
Int button, x, y;
Void * p;
Size_t area;
/ * menu structure * /
Struct MENU
{
/ * top left * /
Int x;
Int y;
/ * bottom right corner * /
Int the x1;
Int y1.
Unsigned char Active [MAX_MENU]; The / * menu item is active in the symbol * /
Char * head; / * the name of the menu (optional) * /
};
Int MouseOn.
Void the Process ();
Void Xorbar (int sx, int sy, int ex, int ey, int c);
Void the Show ();
Void Hide ();
Void the Status ();
/ * the user can change the position of the button with the following parameters. * /
Struct MENU File = {200, 110,250, 130}
Struct MENU Edit = {295,110,345,130}
The struct MENU Help = {390, 110,440,130}
Struct MENU Close = {600, 10, 620, 30}
Struct MENU Neeraj = {380,300,460,315}
Void main ()
{
Int gd = DETECT, gm;
/ * initialize the graphical interface * /
Initgraph.
Selection = NONE;
/ does the / * activate the menu item, YES indicates activation; NO means unactivation * /
For (gd = 0; gd < MAX_MENU; g + +)
{
File. The Active (gd) = YES;
Edit. Active [gd] = YES;
Help. Active [gd] = YES;
Close the Active (gd) = YES;
}
/ * the name of the menu item that the user can modify to display other names * /
A. head = "[File Menu]"
Edit: Edit. Head = "[Edit Menu]";
I can't Help you.
Close. Head = "[Exit]";
/ * allocate memory to the interface
Area = imagesize (0, 0, 150, 150);