サポートされているデバイスのピクセル形式を調べる
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);