win11 cb 20.03下安装easyx2021
写了一个鼠标放到选项上,左侧会出现黄色箭头,并且点击或按键盘对应序号能跳转相关页面的函数。
但是左侧箭头经常有概率瞎闪,点击和按键盘有时会失灵,没有进行页面跳转,请问一下是什么问题。
#include <stdio.h>
#include <easyx.h>
#include <graphics.h>
int main()
{
int n=0,m=0;
initgraph(1080,720,EX_SHOWCONSOLE);
ExMessage msg;
settextcolor(YELLOW);
settextstyle(70,0,"宋体",0,0,0,true,false,false);
outtextxy(540-textwidth("主 菜 单")/2,80,"主 菜 单");
settextcolor(WHITE);
settextstyle(50,0,"宋体",0,0,0,false,false,false);
outtextxy(540-textwidth("1.柱状图")/2,200,"1.柱状图");
outtextxy(540-textwidth("2.圆饼图")/2,320,"2.圆饼图");
settextcolor(YELLOW);
while(!m)
{
if(peekmessage(&msg,EX_MOUSE))
{
switch(msg.message)
{
case WM_MOUSEMOVE:
if(540-textwidth("1.柱状图")/2-textwidth("→")<=msg.x&&msg.x<=540+textwidth("1.柱状图")/2&&200<=msg.y&&msg.y<=200+textheight("柱状图"))
outtextxy(540-textwidth("1.柱状图")/2-textwidth("→"),200,"→");
if(540-textwidth("2.圆饼图")/2-textwidth("→")<=msg.x&&msg.x<=540+textwidth("2.圆饼图")/2&&320<=msg.y&&msg.y<=320+textheight("圆饼图"))
outtextxy(540-textwidth("2.圆饼图")/2-textwidth("→"),320,"→");
if(!(540-textwidth("1.柱状图")/2-textwidth("→")<=msg.x&&msg.x<=540+textwidth("1.柱状图")/2&&200<=msg.y&&msg.y<=200+textheight("柱状图")))
clearrectangle(540-textwidth("1.柱状图")/2-textwidth("→"),200,540-textwidth("1.柱状图")/2,200+textheight("→"));
if(!(540-textwidth("2.圆饼图")/2-textwidth("→")<=msg.x&&msg.x<=540+textwidth("2.圆饼图")/2&&320<=msg.y&&msg.y<=320+textheight("圆饼图")))
clearrectangle(540-textwidth("1.柱状图")/2-textwidth("→"),320,540-textwidth("1.柱状图")/2,320+textheight("→"));
break;
case WM_LBUTTONDOWN:
if(540-textwidth("1.柱状图")/2<=msg.x&&msg.x<=540+textwidth("1.柱状图")/2&&200<=msg.y&&msg.y<=200+textheight("柱状图"))
m=1;
if(540-textwidth("2.圆饼图")/2<=msg.x&&msg.x<=540+textwidth("2.圆饼图")/2&&320<=msg.y&&msg.y<=320+textheight("圆饼图"))
m=2;
break;
default:
break;
}
}
if(peekmessage(&msg,EX_KEY))
switch(msg.message)
{
case WM_KEYDOWN:
if(msg.vkcode==97||msg.vkcode==49)
m=1;
if(msg.vkcode==98||msg.vkcode==50)
m=2;
break;
default:
break;
}
}
return 0;
}