' X'按钮不会终止进程

时间:2015-10-30 19:37:16

标签: c++ visual-studio-2013

我在visual studio 2013中制作了一款用c ++编写的小游戏。它创建了一个窗口,在其中绘制了几个东西并弹出我用来调试的控制台。问题是:如果我点击"退出"从我介绍的菜单按钮,一切都很好,过程终止应该是;如果我按下' X'窗口顶部的(关闭)按钮关闭窗口,但控制台仍然存在。因为它应该被排除在外,没有启用控制台并没有修复任何东西:没有与游戏相关联的窗口,但声音仍在播放,并且该过程仍然存在于任务管理器中。我已经对此进行了大量搜索,但我无法找到解决此问题的方法。

我已尝试使用atexit,但该程序并未转到为atexit编写的函数。也许我说错了,我无法说出来。这就是我尝试过的。

void close_win() {
    if (engine)
        engine->drop();
    /*if (SC_CLOSE) {
        cout << "sc_close";
        _exit(0);
    }*/
    cout << "Ceva ";
    exit(0);
}

int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(800, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Aarghhh! O ramaaa !");

    createMenu();     
    glClearColor(0.0, 0.0, 0.0, 0.0);
    init();
    glutReshapeFunc(reshape);
    glutDisplayFunc(dreptunghi);
    glutSpecialFunc(player);
    glutMainLoop();
    atexit(close_win);

    return 0;
}

    BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
    if (CEvent == CTRL_CLOSE_EVENT)
        {
            cout << "You are closing my program.";
        }
        return TRUE;
    }   if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE) == FALSE)
        {
            cout << "The handler is not going to work.";
        }

if (glutGetWindow == 0)
    exit(0);

游戏是在没有课程的情况下制作的,使用OpenGL和GLUT库,如果它对任何事情都很重要。

此外,当我将断点设置为atexit并使用步骤时,经过2个步骤后,调试将停止,并且#34;找不到sehprolg4.asm&#34;。这是否与函数没有调用close_win()有关?

0 个答案:

没有答案