OpenGL 2d picking problem

Hi,
I’m using wxWidgets and wxglCanvas to render a triangle which I want do picking on. The problem is that the area I click is not the object area, it seems that in select mode and rendering mode the two areas doesn’t align. here some important part of my code which is two functions one to render and the other is picking, I just want the hit to me right, RIGHT NOW I culd get a pick where ever I click. pleas help

void TestGLCanvas::[b]render/b
{
SetCurrent();
//glMatrixMode(GL_PROJECTION);
glEnable(GL_DEPTH_TEST);
wxPaintDC dc(this);

glMatrixMode(GL_MODELVIEW);

/* clear color and depth buffers */
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
 glColor3f(0.0f, 1.0f, 0.0f);
     glVertex3f( 0.0f, 0.0f, 0.0f);
 glVertex3f(0.0f, 0.5f, 0.0f);
     glVertex3f(0.5f,0.5f, 0.0f);
    glEnd();
glFlush();
SwapBuffers();

}
void TestGLCanvas::pickBlocks(int button, int state, int x, int y)
{
GLuint selectBuf[512];
GLint hits;
GLint viewport[4];

glGetIntegerv(GL_VIEWPORT, viewport);

glSelectBuffer(512, selectBuf);
(void) glRenderMode(GL_SELECT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y), 5.0, 5.0, viewport);
int w, h;
GetClientSize(&w,&h);
gluPerspective(60.0, (float)w/(float)h, 0, 100);
glInitNames();
glPushName(0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.5f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.0f);
glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glFlush();

hits = glRenderMode(GL_RENDER);
processHits(hits, selectBuf);
}