main_wnd_proc (pstruct -w reply, p_program_state -&w state, p_msg msg)
{
  mouse_button_down ()
  {
    ...
  }

  kbd_input ()
  {
    ...
  }

  paint ()
  {
    ...
  }
  /
  {
    free (&ps);
  }

  select (msg->message)
  {
    case WM_BUTTON_1_DOWN:
      mouse_button_down ();
    return;

    case WM_CHAR:
      kbd_input ();
    return;

    case WM_PAINT:
      paint ();
    return;
  }
  else
  {
    ;
  }
}