maintaining perspective when window resized

I am drawing an opengl object into a display window that can be resized. When the user resizes the window it messes up the perspective since the window may no longer be square. I was wondering what is the correct way to handle this problem. If I center the viewport and make sure it is square then there will be areas outside the viewport but still considered the display window that the model will not be able to get panned into.
Is my only option to always make sure that when a user resizes the window that it maintains a square perspective?

Thanks in advance,

Joe

This is how I do it. It seems to work well for me.

//Change the window size
void ChangeSize(GLsizei w, GLsizei h) {
//Prevent divide by zero
if (h==0) { h = 1;}

//Affects camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

//Set viewport
glViewport(0,0,w,h);

//Feild of view, ratio, start distance, end distance
gluPerspective(45, w / h, 1, 1000);
//Affects models
glMatrixMode(GL_MODELVIEW);

}

better also watch out for the case where the window is higher than it is wide
eg w/h | | h/w