【发布时间】:2011-12-29 05:05:09
【问题描述】:
我正在使用 FLTK。我有一个带有各种按钮的窗口,用户可以单击以执行某些操作。在我的 int main() 中,我有一个 switch 语句来处理所有这些。当用户单击退出时,switch 语句的设置如下:
case Exit_program:
cout << "save files and exit\n";
do_save_exit(sw);
这转到 do_save_exit 函数,该函数创建一个退出确认窗口,其中包含两个按钮是(退出)和否(不退出)。我让“是”按钮工作,退出程序,但“否”按钮意味着我应该隐藏确认窗口。这是以下功能:
void yes(Address addr, Address)
{
exit(0);
}
void no(Address addr, Address)
{
}
void do_save_exit(Window& w)
{
Window quit(Point(w.x()+100, w.y()+100), 250, 55, "Exit confirmation");
Text conf(Point(15,15),"Do you really want to save and exit?");
Button yes(Point(60, 20),35,30,"Yes",yes);
Button no(Point(140, 20),35,30,"No",no);
quit.attach(conf);
quit.attach(yes);
quit.attach(no);
wait_for_main_window_click();
}
问题是,当我单击否按钮时,它会变为无效,但我无法从那里去任何地方。我只想做 quit.hide() 但 no 函数看不到退出窗口(超出范围)。我应该如何进行?谢谢你
P.S:我曾考虑过使用指向退出窗口的指针,然后使用指针在 no 函数中退出窗口,但不知道该怎么做。
【问题讨论】:
标签: c++ user-interface window fltk