Problem with Loading a grahpics resource
I need help with the following bit of code. I am using Visual C++ Compiler and it gives me the following error: "IDR_MAP1 is and undeclared Identifyer". I have already created a script.rc file, and added a group to it called MAPS. I have also already imported a file and Ideentified it as IDR_MAP1 in the group MAPS. Any help would be appreciated!
Here is the code:
#include "stdafx.h"
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HGLOBAL hpic = NULL;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_CLASSDC, WindowProc, 0L, 0L, hInstance, NULL, NULL, NULL, NULL, "GameClass", NULL };
RegisterClassEx(&wcex);
HWND hWnd;
hWnd = CreateWindow("GameClass", "My Game Title", WS_OVERLAPPEDWINDOW,0,0,640,480,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Beginning of the Message Pump
hpic = LoadResource(hInstance, FindResource(hInstance, MAKEINTRESOURCE(IDR_MAP1), "MAPS"));
char *pPic = (char*)LockResource(hpic);
MSG Msg;
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else {
// Add graphics drawing stuff and other cool funcs here
}
}
// End of the Message Pump
UnregisterClass("Gameclass",hInstance);
return 0;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
int tester = NULL;
int xval = 0;
int yval = 0;
switch(uMsg) {
case WM_DESTROY:
tester = MessageBox(hWnd, "Exit Program?", "EXIT BOX",MB_YESNO);
if(tester == IDYES)
PostQuitMessage(0);
break;
default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
PLZ HELP!!
March 10, 2003 06:16 AM
when you created/saved the script file, the IDE should have created a header file called resource.h . you need to #include that file into any source file that is using that graphic.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement