Advertisement

Resource Error w/ my First win32 Programm

Started by June 15, 2002 02:59 AM
8 comments, last by Klear 22 years, 5 months ago
I keep getting this Error: --------------------Configuration: FirstWindow - Win32 Debug-------------------- Compiling resources... ./resources.h(8) : fatal error RC1004: unexpected end of file found Error executing rc.exe. FirstWindow.exe - 1 error(s), 0 warning(s) Here is my code: Main.cpp file
    
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <windowsx.h>

bool RegisterWindowClass();
bool CreateWindowEx(int);
LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);

#define WINDOWCLASS "WINCLASS1"


int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nShowCmd){

	WNDCLASSEX	winclass;
	HWND		hwnd;
	MSG			msg;

	winclass.cbSize			= sizeof(WNDCLASSEX);
	winclass.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
	winclass.lpfnWndProc	= WindowProc;
	winclass.cbClsExtra		= 0;
	winclass.cbWndExtra		= 0;
	winclass.hInstance		= hInstance;
	winclass.hIcon			= LoadIcon(NULL, IDI_EXCLAMATION);
	winclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	winclass.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	winclass.lpszMenuName	= "MainMenu";
	winclass.lpszClassName	= WINDOWCLASS;
	winclass.hIconSm		= LoadIcon(NULL, IDI_EXCLAMATION);

	if(!RegisterClassEx(&winclass))
		return (0);

	if(!(hwnd = CreateWindowEx(NULL,
								WINDOWCLASS,
								"[ First Window ]",
								WS_OVERLAPPEDWINDOW | WS_VISIBLE,
								0,0,
								500,500,
								NULL,
								NULL,
								hInstance,
								NULL)))
		return (0);

	
	//main event loop

	while(GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);

		DispatchMessage(&msg);
	}


	return (msg.wParam);
}

LRESULT CALLBACK WindowProc(HWND hWnd,
							UINT msg,
							WPARAM wparam,
							LPARAM lparam){
	PAINTSTRUCT ps;
	HDC			hdc;
	RECT		rt;

	switch(msg){
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		GetClientRect(hWnd, &rt);
		EndPaint ( hWnd, &ps);
		break;

	case WM_DESTROY:
		PostQuitMessage (0);
		break;

	case WM_KEYDOWN:
		break;

	default:
		return (DefWindowProc(hWnd, msg, wparam, lparam));
	}
	return 0;
}
  

resources.rc file
      
#include <resources.h>

MainMenu MENU DISCARDABLE{
		POPUP "&File"{
			MENUITEM "E&xit", MENUID_EXIT
		}

		POPUP "&Sounds"{
			MENUITEM "Sound &A", MENUID_SOUNDA
			MENUITEM "Sound &B", MENUID_SOUNDB
			MENUITEM "Sound &C", MENUID_SOUNDC
		}
  

resources.h file
      
//MENU: FILE

#define MENUID_EXIT			1000

//MENU: SOUNDS

#define MENUID_SOUNDA		2000
#define MENUID_SOUNDB		2001
#define MENUID_SOUNDC		2002
    
I am still not done(have to respond to menu) but I really want to see what I have done far! Thank YOU!
[edited by - Klear on June 15, 2002 4:02:21 AM] [edited by - Klear on June 15, 2002 4:06:02 AM]
You seem to be missing closing } after the menu definition.
---visit #directxdev on afternet <- not just for directx, despite the name
Advertisement
Unexpected end of file is usually displayed when you have forgotten to put a semi-colon somewhere. Check that all your brackets line up with each other and that there are semi-colons on all the relevant lines. Also try enclosing your case statements in {} (if you are using Visual C++ you can put your break on the end of the } like:


  switch(msg){     case WM_KEYDOWN:     {         MessageBox(NULL,"Hello World","Hello",MB_OK);     }break;     default:break;}  


Hope this helps

[edited by - hammerstein_02 on June 15, 2002 6:12:43 AM]
Alright I added the ''}'' I forgot. I am still having the same error on the same line. I wonder what it is. Any more suggestions?





quote: MSDN on RC1004
This error can be caused by omitting the linefeed and carriage return characters on the last line of a text file.

Could this be the problem?
---visit #directxdev on afternet <- not just for directx, despite the name
That may be it. How would I go about disabling them? I chose to make my resource file myself instead of VS doing it, so I had to use a text file and give it the approprait extension.





Advertisement
Just hit ''Enter'' at the end of the file.
---visit #directxdev on afternet <- not just for directx, despite the name
wow that was gay. it works now. Thanks guys!





Read the docs next time. "1 GB of MSDN and nobody reads it."
---visit #directxdev on afternet <- not just for directx, despite the name
Sorry. I am new to programming. I am not in the habit of looking up errors yet.





This topic is closed to new replies.

Advertisement