unexpected end of file found

i've started learning windows.h programming
i'm stuck at dialogs lesson cuz of this error:

------ Rebuild All started: Project: just another exercise, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'just another exercise', configuration 'Debug|Win32'
Compiling...
new try1.cpp
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
.\resource.h(6) : fatal error RC1004: unexpected end of file found
Build log was saved at "file://c:\Users\Silvio Badak\Desktop\my project\just another exercise\just another exercise\Debug\BuildLog.htm"
just another exercise - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


here's the code
dialog.rc file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS


/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "#include ""windows.h""\r\n"
    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog- I have written only this part in this file, rest is written by tutorial provider
//

ID_DLGOPTIMIZE DIALOG DISCARDABLE 0,0,400,400
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Optimizing"
FONT 8, "Arial"
BEGIN
	DEFPUSHBUTTON "&OK",IDOK, 200,150,50,20
	PUSHBUTTON "&Cancel",IDCANCEL, 300,150,50,20
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    ID_DLGOPTIMIZE, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 232
        TOPMARGIN, 7
        BOTTOMMARGIN, 59
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

resource.h
1
2
3
4
5
6
#define ID_EXIT 1001
#define ID_FILE 1002
#define ID_EDIT 1003
#define ID_VIEW 1004
#define ID_OPTIMIZE 1005
#define ID_DLGOPTIMIZE 2005 

and lastly main.cpp file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "resource.h"
#include <windows.h>

const char CName[]="myClass";

BOOL CALLBACK OptimizeDlgProc (HWND hwnd, UINT msg, WPARAM wParam,LPARAM lParam){
	switch (msg){
		case WM_INITDIALOG :
			break;
		case WM_COMMAND :
			switch (LOWORD(wParam)){
				case IDOK:
					EndDialog (hwnd, IDOK);
					break;
				case IDCANCEL :
					EndDialog (hwnd, IDCANCEL);
					break;
			}
			break;
		default :
			return false;
	}
	return true;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
	switch (msg){
		case WM_CREATE:{
			HMENU hMenu, hSubMenu;

			hMenu = CreateMenu ();
			hSubMenu = CreatePopupMenu ();

			AppendMenu (hSubMenu, MF_STRING, ID_EXIT,"E&xit");
			AppendMenu (hMenu,MF_STRING|MF_POPUP, (UINT)hSubMenu, "&File");

			hSubMenu = CreatePopupMenu ();
			AppendMenu (hSubMenu, MF_STRING,ID_VIEW,"&View");
			AppendMenu(hSubMenu, MF_STRING, ID_OPTIMIZE, "O&ptimize");
			AppendMenu (hMenu,MF_STRING|MF_POPUP, (UINT)hSubMenu,"&Edit");
			SetMenu(hwnd,hMenu);
			}
			break;
		case WM_COMMAND :
			switch (LOWORD (wParam)){
				case ID_EXIT:
					SendMessage (hwnd, WM_CLOSE, NULL,NULL);
					break;
				case ID_VIEW :
					MessageBox (hwnd, "View your head, u might find sth there","Info", MB_OK);
					break;
				case ID_OPTIMIZE :
					DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(ID_DLGOPTIMIZE),hwnd,OptimizeDlgProc);
					break;
			}
			break;
		case WM_CLOSE:
			PostQuitMessage (0);
			break;
		case WM_DESTROY : 
			DestroyWindow (hwnd);
			break;
		default :
			break;
	}
	return DefWindowProc (hwnd, msg, wParam, lParam);
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
	HWND hwnd;
	WNDCLASSEX wc;
	MSG msg;

	wc.cbSize = sizeof (WNDCLASSEX);
	wc.style = 0;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor (NULL,IDC_ARROW);
	wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	wc.lpszClassName = CName;
	wc.lpszMenuName = NULL;
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
	wc.hIconSm = NULL;

	hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, 
		CName, 
		"Program", 
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,CW_USEDEFAULT, 
		400,400, NULL,NULL,
		hInstance, NULL);
	if (hwnd == NULL){
		MessageBox (hwnd, "Window creation failed!","Error", MB_OK|MB_ICONWARNING);
		return 1;
	}

	ShowWindow (hwnd, nCmdShow);
	UpdateWindow (hwnd);

	while (GetMessage(&msg,hwnd, NULL,NULL)>0){
		TranslateMessage (&msg);
		DispatchMessage (&msg);
	}

	return msg.wParam;
}
Last edited on
.\resource.h(6) : fatal error RC1004: unexpected end of file found
Can you post resource.h, as that's where the error is.
The resource header file should have a blank line at the end ( a strange thing I know)
Like this:
1
2
3
4
5
6
7
#define ID_EXIT 1001
#define ID_FILE 1002
#define ID_EDIT 1003
#define ID_VIEW 1004
#define ID_OPTIMIZE 1005
#define ID_DLGOPTIMIZE 2005
 

^thanks!
Topic archived. No new replies allowed.