Hello dear Toradex community,
I have a Silverlight application for WinCE7 on a Toradex T20 module, which is written in C++
Now I want to implement a screenshot feature that saves the whole screen content into a bitmap file.
I found many examples for this. The following code snippet should load the whole screen into a bitmap:
const POINT tlp = DetermineTopLeftCornerPosition(); const POINT brp = DetermineBottomRightCornerPosition(); DWORD err; HWND windowHandle = NULL; HDC hs = GetDC(NULL); HDC hdc = CreateCompatibleDC(hs); HBITMAP hb = CreateCompatibleBitmap(hs, abs(brp.x - tlp.x), abs(brp.y - tlp.y)); HGDIOBJ ho = SelectObject(hdc, hb); DWORD err = GetLastError(); BitBlt(hdc, 0, 0, abs(brp.x - tlp.x), abs(brp.y - tlp.y), hs, tlp.x, tlp.y, SRCCOPY);
The problem seems to lie in the function
SelectObject(...). The following call of
GetLastError(), gives me the error code 6, which indicates an invalid handle.
On my PC (Win10) this code does work, but not on CE.
Does anyone have an idea what I am doing wrong here?
Many thanks in advance for helpful answers.