You seem to have missed a step, namely SetPixelFormat(hDC,PixelFormat,&pfd)