Harvey Chapman wrote:
> Normally, I have "return Fl::run()" at the end of my programs. However, 
> I'm currently writing an app that should appear and disappear 
> periodically. Fl::run() does not work in this case because it exits when 
> no more windows are visible. Is there a way to keep going as long as any 
> window exists or perhaps as long as my main window exists?
> 
> Something like...
> 
> while (any_window_exists) wait(FOREVER);
> 
> or
> 
> // Not sure how this would work...
> Fl_Window *w;
>  while (w_exists) wait(FOREVER);

Hmm, what do you mean with "exists", as opposed to "visible"? A window 
that is hidden, does still exist as an object, until you delete it, and 
you can't delete static objects until the program exits. But see below.

> Actually, I guess I could just do it the old fashioned way:
> 
> bool quit = false;
> while (!quit) wait(FOREVER);

Matthias explained already how Fl::run() works.

Maybe you mean something like:

Fl_Window main_win (...);
// initialize program...

bool quit = false;
while (!quit) {
   main_win.show();
   Fl::run();

   // determine how long to wait ...

   if ( <end_of_program> )
     quit = true;
   else
     sleep(10); // e.g. replace by your own logic
}

This would automatically raise the main window 10 seconds after the last 
window (probably the main window?) has been closed and Fl::run() returned.

There's nothing wrong with calling Fl::run() more than once (in a loop).

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to