Points & Lines Selection

I am having difficulty with selection of a point of line using the following function in MFC.

#define BUFFER_LENGTH 512
void CPlanView::ProcessSelection(double xPos, double yPos)
{
// Space for selection buffer
GLuint selectBuf[BUFFER_LENGTH];

// Hit counter and viewport storage
GLint hits;
GLint viewport[4];

// Get the viewport
glGetIntegerv(GL_VIEWPORT, viewport);
// Setup selection buffer
glSelectBuffer(BUFFER_LENGTH, selectBuf);
// Change render mode
glRenderMode(GL_SELECT);

glInitNames();
glPushName(0);

// Switch to projection and save the matrix
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

gluPickMatrix((GLdouble)xPos, (GLdouble)(viewport[3] - yPos), 2.0, 2.0, viewport);

glOrtho(xPos-10, xPos+10, yPos-10, yPos+10, -1, 2);

// Draw the scene
RenderScene();

// Collect the hits
hits = glRenderMode(GL_RENDER);
glPopMatrix();
glFlush();

// If a single hit occured, display the MB.
if(hits == 1)
{
	  MessageBox("Success!.", "Hit!", MB_ICONEXCLAMATION | MB_OK);
}

// Go back to modelview for normal rendering
glMatrixMode(GL_MODELVIEW);

}

It works for GL_QUADS though. I am also unclear as to what volume glOrtho() should create. If I use the whole viewport the function does not work.
Thanks in advance.