Есть заддача отрисовать рабочий стол. Пока устраивала отрисовка на форму, всё работало.
HWND iHwnd;
case WM_PAINT:
PAINTSTRUCT lPS;
HDC lBase = ::BeginPaint(iHwnd, &lPS);
BOOL lRes = ::PaintDesktop(lBase);
DWORD lErrorCode = ::GetLastError();
::EndPaint(iHwnd, &lPS);
Результат:lRes == TRUE (Success)
lErrorCode == ERROR_SUCCESS ("The operation completed successfully")
Но, как только понадобилась отрисовка в bitmap, начались, непонятные мне, проблемы.
int lWidth = 1024;
int lHeight = 738;
HDC lBase = ::CreateDC(L"DISPLAY", NULL, NULL, NULL);
HDC lBitmapDC = ::CreateCompatibleDC(lBase);
HBITMAP lBitmap = ::CreateCompatibleBitmap(lBase, lWidth, lHeight);
HGDIOBJ lNullBitmap = ::SelectObject(lBitmapDC, lBitmap);
BOOL lRes = ::PaintDesktop(lBitmapDC);
DWORD lErrorCode = ::GetLastError();
::SelectObject(lBitmapDC, lNullBitmap);
::DeleteDC(lBitmapDC);
::DeleteObject(lBitmap);
Результат:lRes == FALSE (Error)
lErrorCode == ERROR_FILE_NOT_FOUND ("The system cannot find the file specified")
Как понятно, ничего в bitmap не отрисовывается. К чему бы это?
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>
07.11.06 13:44: Перенесено модератором из 'WIN API' — Odi$$ey
Здравствуйте, spbAngel, Вы писали:
A>lErrorCode == ERROR_FILE_NOT_FOUND ("The system cannot find the file specified")
Объясните, pls, какой "файл" он не находит?
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>
Здравствуйте, spbAngel, Вы писали:
[...]
http://blogs.msdn.com/oldnewthing/archive/2003/10/09/55243.aspx
>>BTW: can you explain why PaintDesktop fails with memory device context on 2k/XP?
Raymond Chen:
>You can't PaintDesktop into a memory DC because PaintDesktop does an EnumDisplayMonitors to render the desktop on each monitor, but a memory DC doesn't have any monitors.