//初始化 if(initscr() == NULL) { perror("initcurs") exit(EXIT_FAILURE) } cbreak() noecho() keypad(stdscr, TRUE) //建立菜单项 for(i=0 i<N_ITEMS i++){ items[i] = new_item(months[i], "") } //建立菜单 mymenu = new_menu(items) //设置为5行单列的菜单 set_menu_format(mymenu, 5, 1) set_menu_mark(mymenu, "*") //获得菜单的行数很列数 scale_menu(mymenu, &mrows, &mcols) //建立窗口和子窗口 win = newwin(mrows + 2, mcols + 2, 3, 30) keypad(win, TRUE) box(win, 0, 0) subwin = derwin(win, 0, 0, 1, 1) //设置菜单的窗口 set_menu_sub(mymenu, subwin) //在子窗口上放置菜单 post_menu(mymenu) refresh() wrefresh(win)