> This works, but doesn't solve the problem of some of the
> opened window
> having pending work to be done.
>
> If some opened window has a pending work how we can allow the
> user to
> cancel the application to exit and finish the pending work ?
You probably need a "dirty" flag so you can tell which windows might
need further processing.
Something like this might work...
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/fl_ask.H> // fl_alert, fl_choice, etc.
class CloseWin : public Fl_Double_Window {
public:
int dirty;
CloseWin(int W, int H, char *L) : Fl_Double_Window(W, H, L) {
dirty = 0;
};
void close_hide(void){
if(dirty) {
fl_alert("Window has unsaved data!");
}
else {
hide();
}
};
};
static void cb_close(Fl_Widget*, void*) {
Fl_Window *win = Fl::first_window();
while(win) {
CloseWin *tmp = (CloseWin *)win;
win = Fl::next_window(win);
tmp->close_hide();
}
}
int main(int argc, char **argv) {
CloseWin *w1 = new CloseWin(500, 300, "Win 1");
w1->box(FL_FLAT_BOX);
w1->end();
w1->callback(cb_close);
CloseWin *w2 = new CloseWin(500, 300, "Win 2");
w2->box(FL_FLAT_BOX);
w2->end();
CloseWin *w3 = new CloseWin(500, 300, "Win 3");
w3->box(FL_FLAT_BOX);
w3->end();
w3->dirty = 1;
w1->show(argc, argv);
w2->show();
w3->show();
return Fl::run();
}
/* end of file */
SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14
3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk