LoadImage is not working with MAKEINTRESOURCE

Saif Resun 46 Reputation points
2022-02-13T06:55:03.32+00:00

Hello there! I am trying to load an image from the resources here's my code which is not working:

the resource.h:

#define IDB_BITMAP1                     103

the main source code:

HANDLE  start_img = LoadImage(NULL, MAKEINTRESOURCE(103), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);

if (start_img == NULL)
{
    return 0;
}

However, the file path instead of MAKEINTRESOURCE is working. Here's the code:

HANDLE  start_img = LoadImage(NULL, L"C:\\Users\\_resun\\Desktop\\play.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);

can someone please help me?

Thank you.

Windows development | Windows API - Win32
Developer technologies | C++
{count} vote

Accepted answer
  1. Castorix31 90,681 Reputation points
    2022-02-13T07:29:13.35+00:00

    Use :

     HANDLE  start_img = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(103), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.