檢查裝置支援的像素格式
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);