easyX制作菜单页面

Last updated on 2 years ago

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <graphics.h>
void start()//开始按钮
{
outtextxy(500,300,"start");
rectangle(370,290,650,320);
}
void startif()//判断鼠标是否在按钮内,是否点击
{
ExMessage msg ;
while(1)
{
do
{ peekmessage(&msg);
if(msg.x >= 370 && msg.x <= 650 && msg.y >= 290 && msg.y <= 320)//在按钮内则按钮变红
{ cleardevice();
BeginBatchDraw();
settextcolor(RED);
setlinecolor(RED);
start();
FlushBatchDraw();
}
else//按钮外变白
{
cleardevice();
settextcolor(WHITE);
setlinecolor(WHITE);
start();
FlushBatchDraw();
}

}while(!msg.lbutton || !(msg.x >= 370 && msg.x <= 650 && msg.y >= 290 && msg.y <= 320));//左键退出
printf("开始");
break;

}
}

正常效果

鼠标停留效果

不难写,但要注意BeginBatchDraw()FludBatchDraw() 的位置,不加会闪。