How to implement select-pick operation using VC++6.0

I want to select and pick objects using VC++6. Where does this function as follows will be put, in OnDraw() or OnLButtonDown()?
How do I do?
PickPoint(int x,int y)
{
GLuint selectBuf[BUFSIZE];
GLint hits;

glGetIntegerv(GL_VIEWPORT, viewport);

glSelectBuffer (BUFSIZE, selectBuf);
(void) glRenderMode (GL_SELECT);

glInitNames();
glPushName(-1);

glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gluPickMatrix((GLdouble)x, (GLdouble) (viewport[3] - y), 18, 18, viewport);
gluPerspective(35.0, (GLfloat)viewport[2]/(GLfloat)viewport[3], 1.0f, 5000.0f);

DrawMyObjects(GL_SELECT);

glPopMatrix ();

glFlush ();

hits = glRenderMode(GL_RENDER);
}

Thanks!!!

That function must be put in the mouse down of course, or you’ll end calling infinite times the rendering himself recursively…

Try to understand what it does before cut n’ pasting it. ;D

rIO.sK http://www.spinningkids.org/rio