首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

SetPixelFormat函数返回值替false的原因有哪些?

2012-10-12 
SetPixelFormat函数返回值为false的原因有哪些??如题,这个函数返回值一直是false,很郁闷啊求大神~~~[解决

SetPixelFormat函数返回值为false的原因有哪些??
如题,这个函数返回值一直是false,很郁闷啊

求大神~~~

[解决办法]
虽然没用过这个函数,还是给你几个建议。
1,查看msdn对返回值的详细解释
2,GetLastError获得错误码,在vs的错误查找工具中查看具体错误原因
[解决办法]
不给上下文代码,只能用GetLastError自己排查了
[解决办法]
象素格式不是任意设置就 ok 的,
你没有一个判断函数么?

C/C++ code
boolCGLWindowLite::setPixelFormat(HDC hdc, int colorBits, int depthBits, int stencilBits){  PIXELFORMATDESCRIPTOR pfd;  // find out the best matched pixel format  int pixelFormat = findPixelFormat(hdc, colorBits, depthBits, stencilBits);  if(pixelFormat == 0)    return false;  // set members of PIXELFORMATDESCRIPTOR with given mode ID  ::DescribePixelFormat(hdc, pixelFormat, sizeof(pfd), &pfd);  // set the fixel format  if(!::SetPixelFormat(hdc, pixelFormat, &pfd))    return false;  return true;} 

热点排行