0

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.

4

1 に答える 1

1

GetBitmap() の呼び出しは、最初ではなく 2 番目に失敗します。

その場合、2 つのクラス インスタンスが同じハンドルを保持する方法はなく、コード スニペットはまさにこれを示唆しています。デバッガーでブレークして、実際に内部に保持されているものを確認firstして確認できます。second

于 2012-04-18T10:46:40.790 に答える