PIXELFORMATDESCTIPTOR problem

Hi everyone,

I'm relatively new to OpenGL programming. I successfully wrote an application with freeGLUT and GLEW displaying some triangles and some textures.
Now I wanted to create an application without freeGLUT.
The problem is that "ChoosePixelFormat()" always returns 0 instead of some matching number.
Here is my PIXELFORMATDESCRIPTOR:

First of all, use PIXELFORMATDESCRIPTOR as a structure, and set parameters by name.
Second, unlike setting pixel format, choosing is not "malicious" operation and you can call it unlimited number of times without any convenience.
Third, what's GetLastError saying?

I set the parameters by name and called GetLastError, here is the error message:
"ChoosePixelFormat failed with error 6: the handle is invalid"
So it's clear what I've done wrong, I didn't retrieve the device context properly
Now it's working just fine.
I should get more comfortable with the Win32 API I think