#include <stdio.h>
#include "graphapp.h"
App *app;
void close_it(Window *w)
{
char *filename = NULL;
int result = ask_yes_no_cancel(app, "Confirm Save", "Save changes?");
if (result == YES) {
filename = ask_file_save(app, "Save File",
"Save the file as:",
get_control_text(w));
if (filename == NULL) /* operation cancelled! */
return;
/* save the file somehow */
ask_ok(app, "File Saved", "The file was sucessfully saved.");
}
else if (result == CANCEL)
return;
hide_window(w);
}
int main(int argc, char *argv[])
{
Window *w1, *w2;
app = new_app(argc, argv);
w1 = new_window(app, rect(0,0,300,250), "file1.txt", STANDARD_WINDOW);
set_close(w1, close_it);
show_window(w1);
w2 = new_window(app, rect(20,20,300,250), "file2.txt", STANDARD_WINDOW);
set_close(w2, close_it);
show_window(w2);
main_loop(app);
return 0;
}
Notes: