Does anyone see any reason why LoadResource would return NULL in this code? I''m using MSVC++ 6.0. I''m just trying to load a custom resource, but it always fails. For some reason, it can''t find the resource.
I inserted the resource by going to Insert|Resource, clicked custom and typed in TEXT. Then it automatically created IDR_TEXT1. Then I just typed the test string into the resource, using the resource editor. I saved all files, and compiled. Am I missing something in adding and loading a custom resource?
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
hInstance=hInst;
hResource = LoadResource (hInstance,
FindResource (hInstance, "TEXT",
MAKEINTRESOURCE (IDR_TEXT1))) ;
if (hResource==NULL){MessageBox(NULL,"hResource is NULL","Status", MB_OK);}
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1),
hWnd, reinterpret_cast<DLGPROC>(DlgProc));
return FALSE;
}
resource.h:
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Script1.rc
//
#define IDD_DIALOG1 101
#define IDR_MENU1 102
#define IDR_TEXT1 103
#define FILE_POPUP 40001
#define ID_FILE_EXIT 40002
#define FILE_EXIT 40002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40003
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
This is in my resource script:
IDR_TEXT1 TEXT DISCARDABLE "text1.bin"