I hope this is the right place for my issue. I am using the functions ChoosePixelFormat, SetPixelFormat and wglMakeCurrent on a Windows 7 laptop which is equipped with a NVidia Quadro k1000M graphics card. In my project I have specified a certain pixel format and by using ChoosePixelFormat I obtain the index for the closest match. However, calling SetPixelFormat subsequently with the index and specified pixel format yields FALSE as return value and the last error is set to 0xc0070006. This was confusing since ChoosePixelFormat did not return 0 but a valid index.
I then iterated over all possible indices (400 something in total) and found that SetPixelFormat returns TRUE for only about a dozen of them in conjunction with my desired pixel format.
Consequently I chose one of the dozen seemingly working pixel formats and called SetPixelFormat. Next I tried to call wglMakeCurrent which returned FALSE with the last error being 0x7d0 ( 2000 in decimal): "The pixel format is invalid".
This entire issue seems to only persists on systems with NVidia graphic cards. The code works for instance on systems with Intel graphic cards. Does anyone have a clue on what is going on, if this is a known issue and, most importantly, if there is a fix?

Here is the code I used
Code :
memset(&pfd, 0, sizeof(pfd));
pfd.nSize         = sizeof(pfd);
pfd.nVersion      = 1;
pfd.iPixelType    = PFD_TYPE_RGBA;
pfd.cColorBits    = 32;
pfd.iLayerType    = PFD_MAIN_PLANE;
int format = ChoosePixelFormat(*hdc, &pfd);
BOOL success = SetPixelFormat(*hdc, format, &pfd);
DWORD el = GetLastError();
success = wglMakeCurrent(*hdc, context);
el = GetLastError();