当屏幕解决方案更改时,为什么CreateDIBSection返回NULL而GetLastError返回0?

以下是我的代码:
void Fun(int nScreenWidth, int nScreenHeight)
{
...
int nMemSize = nScreenWidth*nScreenHeight*3*7

HDC hdc = ::GetDC(hWnd);
int hBmpMapFile = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, nMemSize, NULL);

BITMAPINFO bmpInfo = {0};
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = 7*nScreenWidth;
bmpInfo.bmiHeader.biHeight = nScreenHeight;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = 0;
bmpInfo.bmiHeader.biSizeImage = nMemSize;
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
bmpInfo.bmiHeader.biClrUsed = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
bmpInfo.bmiColors[0].rgbBlue = 204;
bmpInfo.bmiColors[0].rgbGreen = 204;
bmpInfo.bmiColors[0].rgbRed = 204;
bmpInfo.bmiColors[0].rgbReserved = 0;
PVOID pvBits = NULL;
HBITMAP hBmpWallpaper = ::CreateDIBSection(hdc, &bmpInfo, DIB_RGB_COLORS, &pvBits, hBmpMapFile, 0);
DWORD dwErr = ::GetLastErr();
...
}
我的操作系统是windows xp,屏幕分辨率是1024 * 768,调用功能:
Fun(1024, 768);
我发现CreateDIBSection返回NULL而GetLastErr()重新开始0.但是当屏幕分辨率为2048 * 1536时,调用函数:
Fun(2048, 1536);
我发现CreateDIBSection返回一个有效的句柄。 为什么? 看来屏幕分辨率导致CreateDIBSection重新出现无效值,我不知道为什么。 但在某些WINXP中,CreateDIBSection总是会成功完成屏幕重制。 从测试来看,我认为原因与HDC有关。 HDC与屏幕分辨率有关吗?     
已邀请:

要回复问题请先登录注册