When constructing windows, I usually don't call show()
        on a window until it's fully constructed.

        So eg. moving the window.show() after the end()s for both
        windows should fix your example as well. (Just tried it on
        linux and I get the same behavior as your examples, and if
        I move window.show() to the end that makes it "work" just like
        the second example)

        I've always thought of Fl_Window::show() as a special case
        that really creates (maps) the physical window, and that it
        should be done "last".

        At some point FLTK has to decide whether a window is going
        to be parented to another window, or be a standalone physical
        window, and I think it's during show() that this happens.

        Thing is, if you were making a program where you could drag
        one physical window into another so that it 'snaps in' becoming
        a subwindow, one would think this re-parenting could be done with
        Fl_Window::add() (which is what the first example is trying to show
        I think), but it might be different because FLTK's event loop hasn't
        been called yet, so the behavior might be different than during
        a construction.

[email protected] wrote:
> ..this doesn't work (running on XP):
> 
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> int main (int argc, char ** argv)
> {
>     Fl_Window window(300, 300, "big window");
>     window.show();
>     Fl_Window sub(10, 10, 100, 100, "sub");
>     sub.color(FL_RED);
>     sub.end();
>     window.end();
>     sub.show();
>     return(Fl::run());
> }
> 
> But this does:
> 
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> int main (int argc, char ** argv)
> {
>     Fl_Window window(300, 300, "big window");
>     window.end();
>     window.show();
>     Fl_Window sub(10, 10, 100, 100, "sub");
>     sub.color(FL_RED);
>     sub.end();
>     window.add(sub);
>     sub.show();
>     return(Fl::run());
> }
> 
> Having had problems of my own with subwindows in the past,
> I'm sort of curious.  Anybody know what's up?
> 
> Thanks,
> Stan
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to