Greg Ercolano wrote:
> Looking at the intentions of your TestWin class,
> here's what I think you want:
>
> ---- snip
> [..]
> ---- snip
One thing I forgot in that last example is to end() NuWin.
Small mod to last program plus some added comments for clarification.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
// Create a custom class
class TestWin : public Fl_Double_Window
{
Fl_Button *But; // button we'll use to invoke callback
Fl_Double_Window *NuWin; // pointer to second window we show
when button pushed
// Callback defined inside class
static void Button_CB(Fl_Widget *w, // this pointer will be the button
itself
void *v) // this will be a pointer to the
TestWin instance ('this' or 'self')
{
TestWin* tWin = (TestWin*)v; // userdata is pointer to self
tWin->NuWin->show(); // resolve NuWin through pointer to self
}
public:
// Ctor
TestWin(int w, int h, const char* c=0) : Fl_Double_Window(w,h,c)
{
// Create button inside window
But = new Fl_Button(40, 50, 75, 30, "CB Test");
But->callback(Button_CB, (void*)this); // configure
callback with userdata as pointer to self
end(); // end main
window
// Create a separate physical window
NuWin = new Fl_Double_Window(50, 100, "Hooray!"); // create new
window, save pointer to it
NuWin->end(); // end new
window
}
};
int main()
{
TestWin *tWin = new TestWin(150,150,"Test"); // create instance of
custom class
tWin->show(); // show the custom
class window
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk