/* * Win2 * ---- * This program creates two windows, demonstrating one way to * create and use more than one window at the same time. * * It is an extension on the program savefile.c and handles * the situation where the user cancels file saving inside * the "save as" dialog box. */ #include void close_it(window w) { char *filename = NULL; int result = askyesnocancel("Save changes?"); if (result == YES) { filename = askfilesave(NULL, gettext(w)); if (filename == NULL) /* operation cancelled! */ return; /* save the file somehow ... */ askok("The file was sucessfully saved."); } else if (result == CANCEL) return; hide(w); } void main(void) { window w1, w2; w1 = newwindow("file1.txt", rect(0,0,300,250), StandardWindow); setclose(w1, close_it); show(w1); w2 = newwindow("file2.txt", rect(20,20,300,250), StandardWindow); setclose(w2, close_it); show(w2); mainloop(); }