Garmaine Staff asked 2 years ago

I am trying to load an image resource using the LoadImageA() function, yet it doesn't work and I don't understand why.

Here's a bit of my code :

bool isRessource = IS_INTRESOURCE(107);

// Load the resource to the HGLOBAL.
HGLOBAL imageResDataHandle = LoadImageA(
    NULL,
    MAKEINTRESOURCEA(107),
    IMAGE_BITMAP,
    0,
    0,
    LR_SHARED
    );
HRESULT hr = (imageResDataHandle ? S_OK : E_FAIL);

The image I want to load is a bitmap saved in the resources, and represented as such within resources.h:

#define IDB_BITMAP1                     107

When I execute the code, isRessource is equal to true, yet hr is equal to E_FAIL.

Any idea as to why this is happening? I am using Visual Studio 2019, and I made the image using Gimp.