[Dev-C++] Parse Error in Resource File only in Dev
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Andre M. B. <ab...@cp...> - 2004-12-23 15:12:58
|
Dear Users,
I have a project file which is a Charles Petzold, chapter 10,=20
poppad2.c example.
=20
All example files from this book are made for Visual C++. Up to this
example in this chapter I am getting success to adapt them to Dev.
But this example is presenting one parse error that I can=B4t discover
what=B4s grong.=20
-->Here are the codes:
///////////////////////////////
***file "poppad2.c"
#include <windows.h>
#include "resource.h"
#define ID_EDIT 1
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
TCHAR szAppName[] =3D TEXT ("PopPad2") ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HACCEL hAccel ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style =3D CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc =3D WndProc ;
wndclass.cbClsExtra =3D 0 ;
wndclass.cbWndExtra =3D 0 ;
wndclass.hInstance =3D hInstance ;
wndclass.hIcon =3D LoadIcon (hInstance, szAppName) ;
wndclass.hCursor =3D LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground =3D (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName =3D szAppName ;
wndclass.lpszClassName =3D szAppName ;
=20
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
=20
hwnd =3D CreateWindow (szAppName, szAppName,
WS_OVERLAPPEDWINDOW,
GetSystemMetrics (SM_CXSCREEN) / 4,
GetSystemMetrics (SM_CYSCREEN) / 4,
GetSystemMetrics (SM_CXSCREEN) / 2,
GetSystemMetrics (SM_CYSCREEN) / 2,
NULL, NULL, hInstance, NULL) ;
=20
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;=20
=20
hAccel =3D LoadAccelerators (hInstance, szAppName) ;
=20
while (GetMessage (&msg, NULL, 0, 0))
{
if (!TranslateAccelerator (hwnd, hAccel, &msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return msg.wParam ;
}
AskConfirmation (HWND hwnd)
{
return MessageBox (hwnd, TEXT ("Really want to close PopPad2?"),
szAppName, MB_YESNO | MB_ICONQUESTION) ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM=20
lParam)
{
static HWND hwndEdit ;
int iSelect, iEnable ;
=20
switch (message)
{
case WM_CREATE:
hwndEdit =3D CreateWindow (TEXT ("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSC=
ROLL |
WS_BORDER | ES_LEFT | ES_MULTILINE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0, hwnd, (HMENU) ID_EDIT,
((LPCREATESTRUCT) lParam)->hInstance, NULL)=
;
return 0 ;
=20
case WM_SETFOCUS:
SetFocus (hwndEdit) ;
return 0 ;
=20
case WM_SIZE:=20
MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), T=
RUE) ;
return 0 ;
=20
case WM_INITMENUPOPUP:
if (lParam =3D=3D 1)
{
EnableMenuItem ((HMENU) wParam, IDM_EDIT_UNDO,
SendMessage (hwndEdit, EM_CANUNDO, 0, 0) ?
MF_ENABLED : MF_GRAYED) ;
=20
EnableMenuItem ((HMENU) wParam, IDM_EDIT_PASTE,
IsClipboardFormatAvailable (CF_TEXT) ?
MF_ENABLED : MF_GRAYED) ;
=20
iSelect =3D SendMessage (hwndEdit, EM_GETSEL, 0, 0) ;
=20
if (HIWORD (iSelect) =3D=3D LOWORD (iSelect))
iEnable =3D MF_GRAYED ;
else
iEnable =3D MF_ENABLED ;
=20
EnableMenuItem ((HMENU) wParam, IDM_EDIT_CUT, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_COPY, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_CLEAR, iEnable) ;
return 0 ;
}
break ;
case WM_COMMAND:
if (lParam)
{
if (LOWORD (lParam) =3D=3D ID_EDIT &&
(HIWORD (wParam) =3D=3D EN_ERRSPACE ||
HIWORD (wParam) =3D=3D EN_MAXTEXT))
MessageBox (hwnd, TEXT ("Edit control out of space.")=
,
szAppName, MB_OK | MB_ICONSTOP) ;
return 0 ;
}
else switch (LOWORD (wParam))
{
case IDM_FILE_NEW:
case IDM_FILE_OPEN:
case IDM_FILE_SAVE:
case IDM_FILE_SAVE_AS:
case IDM_FILE_PRINT:
MessageBeep (0) ;
return 0 ;
=20
case IDM_APP_EXIT:
SendMessage (hwnd, WM_CLOSE, 0, 0) ;
return 0 ;
case IDM_EDIT_UNDO:
SendMessage (hwndEdit, WM_UNDO, 0, 0) ;
return 0 ;
=20
case IDM_EDIT_CUT:
SendMessage (hwndEdit, WM_CUT, 0, 0) ;
return 0 ;
=20
case IDM_EDIT_COPY:
SendMessage (hwndEdit, WM_COPY, 0, 0) ;
return 0 ;
=20
case IDM_EDIT_PASTE:
SendMessage (hwndEdit, WM_PASTE, 0, 0) ;
return 0 ;
=20
case IDM_EDIT_CLEAR:
SendMessage (hwndEdit, WM_CLEAR, 0, 0) ;
return 0 ;
case IDM_EDIT_SELECT_ALL:
SendMessage (hwndEdit, EM_SETSEL, 0, -1) ;
return 0 ;
=20
case IDM_HELP_HELP:
MessageBox (hwnd, TEXT ("Help not yet implemented!"),
szAppName, MB_OK | MB_ICONEXCLAMATION) ;
return 0 ;
=20
case IDM_APP_ABOUT:
MessageBox (hwnd, TEXT ("POPPAD2 (c) Charles Petzold, 1998=
"),
szAppName, MB_OK | MB_ICONINFORMATION) ;
return 0 ;
}
break ;
=20
case WM_CLOSE:
if (IDYES =3D=3D AskConfirmation (hwnd))
DestroyWindow (hwnd) ;
return 0 ;
=20
case WM_QUERYENDSESSION:
if (IDYES =3D=3D AskConfirmation (hwnd))
return 1 ;
else
return 0 ;
=20
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
*** end of file poppad2.c
///////////////////////////////////////
///////////////////////////////////////
*** file poppad2.rc
#include "resource.h"
POPPAD2 ICON DISCARDABLE "poppad2.ico"
POPPAD2 MENU DISCARDABLE=20
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", IDM_FILE_NEW
MENUITEM "&Open...", IDM_FILE_OPEN
MENUITEM "&Save", IDM_FILE_SAVE
MENUITEM "Save &As...", IDM_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Print", IDM_FILE_PRINT
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_APP_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z", IDM_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT
MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY
MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE
MENUITEM "De&lete\tDel", IDM_EDIT_CLEAR
MENUITEM SEPARATOR
MENUITEM "&Select All", IDM_EDIT_SELECT_ALL
END
POPUP "&Help"
BEGIN
MENUITEM "&Help...", IDM_HELP_HELP
MENUITEM "&About PopPad2...", IDM_APP_ABOUT
END
END
POPPAD2 ACCELERATORS DISCARDABLE =20
BEGIN
VK_BACK, IDM_EDIT_UNDO, VIRTKEY, ALT, NOINVERT //line=
#38=20
VK_DELETE, IDM_EDIT_CLEAR, VIRTKEY, NOINVERT
VK_DELETE, IDM_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_F1, IDM_HELP_HELP, VIRTKEY, NOINVERT
VK_INSERT, IDM_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
VK_INSERT, IDM_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
"^C", IDM_EDIT_COPY, ASCII, NOINVERT
"^V", IDM_EDIT_PASTE, ASCII, NOINVERT
"^X", IDM_EDIT_CUT, ASCII, NOINVERT
"^Z", IDM_EDIT_UNDO, ASCII, NOINVERT
END
*** end of file poppad2.rc
////////////////////////////////////////////
///////////////////////////////////////////
*** file resource.h
#define IDM_FILE_NEW 40001
#define IDM_FILE_OPEN 40002
#define IDM_FILE_SAVE 40003
#define IDM_FILE_SAVE_AS 40004
#define IDM_FILE_PRINT 40005
#define IDM_APP_EXIT 40006
#define IDM_EDIT_UNDO 40007
#define IDM_EDIT_CUT 40008
#define IDM_EDIT_COPY 40009
#define IDM_EDIT_PASTE 40010
#define IDM_EDIT_CLEAR 40011
#define IDM_EDIT_SELECT_ALL 40012
#define IDM_HELP_HELP 40013
#define IDM_APP_ABOUT 40014
*** end of file resource.h
/////////////////////////////////////////////
-->To show my project options, I think showing you my makefile is
the same thing (I think):
////////////////////////////////
*** file "makefile.win"
# Project: poppad2
# Makefile created by Dev-C++ 4.9.8.0
CPP =3D g++.exe
CC =3D gcc.exe
WINDRES =3D windres.exe
RES =3D poppad2_private.res
OBJ =3D poppad2.o $(RES)
LINKOBJ =3D poppad2.o $(RES)
LIBS =3D -L"C:/Dev-Cpp/lib" -mwindows=20
INCS =3D -I"C:/Dev-Cpp/include"=20
CXXINCS =3D -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw3=
2" -
I"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include"=20
BIN =3D poppad2.exe
CXXFLAGS =3D $(CXXINCS)=20
CFLAGS =3D $(INCS)=20
.PHONY: all all-before all-after clean clean-custom
all: all-before poppad2.exe all-after
clean: clean-custom
rm -f $(OBJ) $(BIN)
$(BIN): $(LINKOBJ)
$(CC) $(LINKOBJ) -o "poppad2.exe" $(LIBS)
poppad2.o: poppad2.c
$(CC) -c poppad2.c -o poppad2.o $(CFLAGS)
poppad2_private.res: poppad2_private.rc poppad2.rc=20
$(WINDRES) -i poppad2_private.rc -I rc -o poppad2_private.res -O coff=20
*** end of makefile.win
/////////////////////////////////
-->The error message after the compilation attempt is:
"Line 38 in file poppad2.rc: parse error"
-->In Visual C++ the example compiles and runs fine.
-->Does anybody know what is the problem?
Regards
Andre
=20
|