我需要知道从屏幕上删除菜单的正确方法是什么。该菜单发布在我专门为其创建的窗口中,请参见代码:
void makeMenu() {
MENU *menu;
WINDOW *win;
ITEM **items;
int choicesC = 4;
items = (ITEM**) calloc(choicesC, sizeof (ITEM*));
for (int i = 0; i < choicesC; i++) {
items[i] = new_item(choices[i], choices[i]);
}
menu = new_menu(items);
win = newwin(10, 40, 4, 4);
keypad(win, true);
set_menu_win(menu, win);
set_menu_sub(menu, derwin(win, 6, 38, 3, 1));
set_menu_mark(menu, "* ");
box(win, 0, 0);
post_menu(menu);
wrefresh(win);
int c;
bool continueB=true;
while ((c = wgetch(win)) != KEY_F(1) && continueB) {
switch (c) {
case KEY_DOWN:
menu_driver(menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(menu, REQ_UP_ITEM);
break;
case 10:
if (current_item(menu)->index== 3) continueB=false;
break;
}
wrefresh(win);
}
unpost_menu(menu);
for (int i=0; i<choicesC; i++){
free_item(items[i]);
}
free_menu(menu);
/* I can't figure out which commands to
call to instantly delete and redraw the menu
wclear(win);
wrefresh(win);
delwin(win);
clear();
refresh();
*/
}
如果我makemenu()
以这种方式调用然后销毁它,则菜单会在下一次 getch() 调用时消失(例如),我希望它在我销毁它时消失。我应该使用哪些命令?
谢谢