Jaywalker
Jaywalker

Reputation: 3119

CBitmap::GetBitmap Failure

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.

Upvotes: 0

Views: 1042

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69672

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.

Upvotes: 1

Related Questions