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 API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
1,986 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,755 questions
1 vote

Accepted answer
  1. Castorix31 69,016 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