# Resizing and Closing Windows

    #include <stdio.h>
    #include "graphapp.h"

    void resize_it(Window w)
    {
      Rect r = get_window_area(w);
      printf("Resize event! New rectangle=(%d,%d,%d,%d)\n",
              r.x, r.y, r.width, r.height);
    }

    void redraw_it(Window w, Graphics *g)
    {
      printf("Draw event!\n);
    }

    void close_it(window w)
    {
      printf("Close event!\n");
      hide_window(w);
    }

    int main(int argc, char *argv[])
    {
      App *app;
      Window *w;

      app = new_app(argc, argv);
      w = newwindow(app, rect(0,0,200,150),
                    "Watch stdout", STANDARD_WINDOW);
      on_window_resize(w, resize_it);
      on_window_redraw(w, redraw_it);
      on_window_close(w, close_it);
      show_window(w);
      main_loop(app);
      return 0;
    }

Notes:

- Windows can be resized and closed, as well as redrawn.
- These events can be intercepted and acted upon.
- If the close event is intercepted, the window will no longer be hidden automatically; you must do it yourself using `hide_window`. This is so you can ask the user if they want to save data, or cancel the operation, for example.