检查设备支持的像素格式
DescribePixelFormat 函数获取设备上下文的像素格式数据。 它还返回一个整数,该整数是设备上下文的最大像素格式索引。 以下代码示例演示如何使用该结果逐步检查设备支持的像素格式:
// local variables
int iMax ;
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat ;
// initialize a pixel format index variable
iPixelFormat = 1;
// keep obtaining and examining pixel format data...
do {
// try to obtain some pixel format data
iMax = DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
// if there was some problem with that...
if (iMax == 0)
// return indicating failure
return(FALSE);
// we have successfully obtained pixel format data
// let's examine the pixel format data...
myPixelFormatExaminer (&pfd);
}
// ...until we've looked at all the device context's pixel formats
while (++iPixelFormat <= iMax);