void main_wnd_proc (pstruct -w reply, p_program_state -&w state, p_msg msg)
                if (msg->message == WM_ADJUST_WINDOW_POSITION)
{
  parent = query_window_rectangle (&_, query_parent_window (msg->window));

  window_position = (p_wp) reply;

  if (window_position->x < 0) window_position->x = 0;
  if (window_position->y < 0) window_position->y = 0;

  if (window_position->x + window_position->cx > parent.cx) window_position->cx = parent.cx - window_position->x;
  if (window_position->y + window_position->cy > parent.cy) window_position->cy = parent.cy - window_position->y;
}