Issues with afxres.rc

JW 61 Reputation points
2024-04-23T10:44:51+00:00

I have some MFC projects that have worked for many years, but suddenly I can no longer access resources from afxres.rc in any of them.

For example, here's a simple test:

CBitmap bitmap;

BOOL success = bitmap.LoadBitmap(AFX_IDB_CHECKLISTBOX_95);

assert( success ); // fails

I can reproduce this error if I create a brand new MFC application (Create a new project -> MFC App, click Create and Finish, using default settings, MFC as a dynamic library). I simply add the three lines of code above to the constructor of the view, and it asserts when running the program.

I searched the internet and found that others who encountered this issue usually had their resources in a separate library, which requires managing module state. This is obviously not the case here. The wizard that creates a new MFC app does not create any libraries. There's just one main project. Also, some people forgot to include "afxres.rc". The project created by the wizard includes this file, so it should be fine.

Please, can you point me to what's wrong or missing? If I call GetLastError, it says "The specified resource name cannot be found in the image file". What is this image file and where can I find it?

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.
3,537 questions
{count} votes