Question

What could be the possible reasons of getting return code as 0 from GetBitmap()?

BITMAP bmInfo;
int rc = bitmap->GetBitmap (&bmInfo);
int ec = GetLastError();

The value returned by GetLastError() is also 0. MSDN doesn't give any help and all the forums where similar questions have been asked are silent.

To give you some context, I have an instance of CBitmap and I am attaching a second instance of CBitmap to the same HBITMAP using code similar to the following:

CBitmap first;
:
:
CBitmap second;
second.Attach ((HBITMAP)first);

BITMAP bmInfo;
second.GetBitmap (&bmInfo);

The call to GetBitmap() fails for second and not for first.

Was it helpful?

Solution

The call to GetBitmap() fails for second and not for first.

If so, there is no way the two class instances hold the same handle, and your code snippet suggests exactly this. You can break with debugger to check your first and second to find out what they are actually holding inside.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top