想利用EGE的图形界面输入框进行选择出现了问题

想利用EGE的图形界面输入框进行选择,然后在进行四则运算,但出现了按下回车无法进行下一步计算的问题,这是我的主界面

img


点击数学功能/四则运算

img

img

想利用输入框进行选择的功能,以下是我的代码:

#include 
#include 
#include 
#include
#include "../Header File/math1-1.h"

void Title_Page();
void Math_Page();
void Four_Operation();

void Title_Page()
{

    initgraph(302,545);
    setbkcolor(WHITE);
    PIMAGE src1;//定义图像
    src1=newimage();//创建图像对象
    getimage(src1,"TitlePage.png");//读取图片
    putimage(0,0,src1);
    for(;is_run();delay_fps(60))
{
    mouse_msg msg={0};
    while(mousemsg())
    {
        msg = getmouse();//以按键按下作为触发鼠标点击条件
    }

    if((msg.x>29&&msg.x<105)&&(msg.y>138&&msg.y<155)&&msg.is_left()&&msg.is_down())
        {
           Math_Page();
        }
    if((msg.x>194&&msg.x<265)&&(msg.y>215&&msg.y<231)&&msg.is_left()&&msg.is_down())
        {
            Life_Page();
        }
     if((msg.x>43&&msg.x<141)&&(msg.y>311&&msg.y<333)&&msg.is_left()&&msg.is_down())
        {
            Computer_Page();
        }
    if((msg.x>223&&msg.x<257)&&(msg.y>431&&msg.y<446)&&msg.is_left()&&msg.is_down())
        closegraph();
    }
}

void Math_Page()
{
    cleardevice();
    PIMAGE src2;//定义图像
    src2=newimage(302,545);//创建图像对象
    getimage(src2,"Math.jpg");//读取图片
    putimage(0,0,src2);
            for(;is_run();delay_fps(60))
            {
                mouse_msg msg={0};
                while(mousemsg())
                {
                    msg=getmouse();//以按键按下作为触发鼠标点击条件
                }
                if((msg.x>201&&msg.x<275)&&(msg.y>188&&msg.y<204)&&msg.is_left()&&msg.is_down())
                {
                    Four_Operation();
                }
                if((msg.x>43&&msg.x<120)&&(msg.y>283&&msg.y<321)&&msg.is_left()&&msg.is_down())
                {
                    Scientific_Operation();
                }
                if((msg.x>185&&msg.x<265)&&(msg.y>390&&msg.y<409)&&msg.is_left()&&msg.is_down())
                {
                    StatisticalFunction();
                }
                if((msg.x>32&&msg.x<132)&&(msg.y>465&&msg.y<483)&&msg.is_left()&&msg.is_down())
                {
                    Title_Page();

            }
        }
}

void Four_Operation()
{
    cleardevice();
    PIMAGE src5;//定义图像
    src5=newimage(302,545);//创建图像对象
    getimage(src5,"FourOperationBk.jpg");//读取图片
    putimage(0,0,src5);

    sys_edit editBox;
    editBox.create(false);
    editBox.size(200, 24 + 8);
    editBox.setbgcolor(YELLOW);
    editBox.setfont(24, 0, "黑体");
    editBox.move(13, 200);
    editBox.visible(true);
    editBox.setfocus();

    sys_edit editBox1;
    editBox1.create(false);
    editBox1.size(200, 24+8);
    editBox1.setbgcolor(YELLOW);
    editBox1.setfont(24, 0, "黑体");
    editBox1.move(13, 288);
    editBox1.visible(true);
    editBox1.setfocus();

   int choice;
   const int buffSize = 100;
   char strBuffer[100];
   char strBuffer1[100];
   double x,y;
   double result;

    for(;is_run();delay_fps(60))
{
    bool calculate = false;

    while (kbmsg()) {
            key_msg msg = getkey();
            if ((msg.key == key_enter) && (msg.msg == key_msg_up)) {
                calculate = true;
            }
        }

        //需要进行计算
        if (calculate) {
            //获取输入框内容字符串
    editBox.gettext(buffSize,  strBuffer);
    sscanf(strBuffer,"%d",&choice);
    editBox1.gettext(buffSize,strBuffer1);
    sscanf(strBuffer1,"%lf%lf",&x,&y);
    switch (choice) {
    case 1:
        result= x + y;
        break;
    case 2:
        result=x - y;
        break;
    case 3:
        result= x * y;
        break;
    case 4:
        result=x / y;
        break;
    default:xyprintf(13,216,"请重新输入\n");
        break;
    }
    xyprintf(13,216,"%lf",result);
        }

    mouse_msg msg={0};
    while(mousemsg())
    {
        msg = getmouse();//以按键按下作为触发鼠标点击条件
    }
    if((msg.x>217&&msg.x<510)&&(msg.y>491&&msg.y<525)&&msg.is_left()&&msg.is_down())
        {
           editBox.destroy();
           editBox1.destroy();
           Math_Page();
        }

}
}


int main()
{
Title_Page();
Math_Page();
Life_Page();
Computer_Page();
Quit();
 getch();
    closegraph();
    return 0;
}

下断点调试下你的回车之后的代码

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^