base.hpp
#ifndef _BASE_HPP_
#define _BASE_HPP_
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#endif//!_BASE_HPP_
demo.cpp
#include "base.hpp"
using namespace std;
Fl_Widget* other=nullptr;
void change( Fl_Widget* o )
{
other->show();
Fl_Button* this_button =(Fl_Button*)o;
other=this_button;
this_button->hide();
}
int main(int argc, char **argv)
{
Fl_Window main_Window( 200, 200, 300, 200, "Window" );
main_Window.begin();
Fl_Button but1( 10, 150, 140, 30, "Click me" );
Fl_Button but2( 10, 100, 140, 30, "It's hide");
other=&but2;
but2.hide();
main_Window.end();
but1.callback(change);
but2.callback(change);
main_Window.show();
return (Fl::run());
}
效果如下

点击Click me会隐藏该按钮并现实It’s hide按钮

2772

被折叠的 条评论
为什么被折叠?



