Anaamika
Anaamika

Reputation: 9

CreateDIBSection is throwing, when trying to create cursor on Win

I am trying to create Cursor from png, and CreateDIBSection() is throwing.

Follwoing is the snippet of code:

HDC hdc = GetDC(NULL);
void* lpBits = NULL;
HBITMAP  hBitmap;
try
{
 hBitmap = CreateDIBSection(
  hdc,
  (BITMAPINFO*)&bi,
  0,
  &lpBits,
  NULL,
  (DWORD)0);
}

ReleaseDC(NULL, hdc);

As CreateDIBSection is throwing, the code to release DC is not getting executed. can you please let me know the possible issue behind this?

Upvotes: 0

Views: 370

Answers (1)

Ashish
Ashish

Reputation: 8529

You should make structure zeroed out:

ZeroMemory(&bi,sizeof(BITMAPV5HEADER));

Try out this link , it may help you :

http://support.microsoft.com/kb/318876

Upvotes: 0

Related Questions