我发现以下代码存在问题:
int ch = 0;
WINDOW *new_window(int x, int y, int w, int h)
{
WINDOW *win;
win = newwin(h, w, y, x);
box(win, '|', '-');
return win;
}
int remove_window(WINDOW *win)
{
delwin(win);
refresh();
}
int showMsgbox(char *title, char *message, int x, int y, int w, int h)
{
WINDOW *msgbox;
msgbox = new_window(x, y, w, h);
mvwprintw(msgbox, 0, 2, title);
mvwprintw(msgbox, 2, 1, message);
mvwprintw(msgbox, h, 2, "Press ENTER...");
wrefresh(msgbox);
while((ch = getch()) != 10) //ENTER
{
wrefresh(msgbox);
}
remove_window(msgbox);
return 0;
}
int main()
{
initscr();
cbreak();
showMsgbox("Hi!", "Hi everybody!", 2, 2, 20, 5);
endwin();
return 0;
}
问题是:当我调用函数showMsgbox时,窗口不可见 (没有编译错误/警告/注释)。 对不起,如果我没有发表评论。 提前谢谢!