> > Joseph wrote:
> > > I have a class which creates a new window whenever a function is run,
> > > but when a button is clicked, i want the window that the button was on
> > > to be closed. How do i do this?
> >
> >     Tell the first window to hide() itself as part of the button's
> >     callback.
>
>
> i have tried that but how do i reference the windows pointer, i cant just do 
> hide();

You can access a pointer to the window within the button callback by setting 
the second argument of the button callback function as a pointer to the window. 
 This tecnique is explained in the 'Hint' described here: 
http://www.fltk.org/doc-1.1/common.html#4_9

#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Button.h>
using namespace fltk;

void cb(Widget *w,void *d){
Window *win=(Window*)d;
win->hide();
}

int main(void){
Window a(400,400,"Window");
a.begin();
Button b(0,0,200,200,"Hide");
b.callback(cb,&a);
a.end();
a.show();
return run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to