OK, I am having a very similar problem. This code is pretty much cut and past from The Forgers web site.
main.cpp
Code:
#include <windows.h>
#include "resource.h"
// define window class name
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_LBUTTONDOWN: {
char szFileName[MAX_PATH];
HINSTANCE hInstance = GetModuleHandle(NULL);
GetModuleFileName(hInstance, szFileName, MAX_PATH);
MessageBox(hwnd, szFileName, "This program is:",
MB_OK | MB_ICONINFORMATION);
break;
}
case WM_CLOSE :
DestroyWindow(hwnd);
break;
case WM_DESTROY :
PostQuitMessage(0);
break;
default :
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
//Step 1: Registering the Window Class
HWND hwnd;
MSG Msg;
WNDCLASSEX wc; // windows class structure
wc.cbSize = sizeof(WNDCLASSEX);//size of the structure
wc.style = 0; //class style
wc.lpfnWndProc = WndProc; //pointer to the procedure for this class
wc.cbClsExtra = 0; //extra memory allocated for this class
wc.cbWndExtra = 0; //extra memory allocated per window
wc.hInstance = hInstance; //handle to the application
wc.hIcon = LoadIcon(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_MYICON));//large icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW);//cursor style
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);//background brush color
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);//name of a menu resource
wc.lpszClassName = g_szClassName;//class name
wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_MYICON),
IMAGE_ICON, 16, 16, 0);//small icon for task bar
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE, // extended windows style
g_szClassName, // class name (from above step)
"A Simple Window", // window title
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // x coord for top left corner of window
CW_USEDEFAULT, // y coord for top left corner of window
640, 420, // width and length of window
NULL, // parent window handle
NULL, // menu handle
hInstance, // application handle
NULL); // pointer to window creation data
if(hwnd == NULL) { // check if window creation failed
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
resource.h
Code:
#define IDR_MYMENU 101
#define IDI_MYICON 201
#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
and menu.rc
Code:
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Stuff"
BEGIN
MENUITEM "&Go", ID_STUFF_GO
MENUITEM "G&o Somewhere Else", 0, GRAYED
END
END
IDI_MYICON ICON "C:\Dev-Cpp\Icons\mainicon.ico"
and here is my compile log
Code:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\References\The_Forger WIN_Tutorials\Chapter 1 Basics\#6, Menus&Icons\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\References\The_Forger WIN_Tutorials\Chapter 1 Basics\#6, Menus&Icons\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -g3
windres.exe -i Menus&Icons_private.rc --input-format=rc -o Menus&Icons_private.res -O coff
windres.exe: Menus: No such file or directory
'Icons_private.rc' is not recognized as an internal or external command,
operable program or batch file.
'Icons_private.res' is not recognized as an internal or external command,
operable program or batch file.
make.exe: *** [Menus&Icons_private.res] Error 1
Execution terminated
this has really baffeled me because it worked the first time I put it in, but has not worked at all after that first time.
everything is included in the project and I have tried the clean and rebuild but that did not change anything.
As Dante Shamest suggested, I looked Under the Project Options, the .rc file has the box for 'Compile as C/C++ Code'
checked but it is grayed out and I cannot change it.
I am not sure where the 'Menus', 'Icons_private.rc' and 'Icons_private.res' came from, as they are not anything
I put in. I am guessing that the compiled automatically creates the '_private' files but I am lost on the 'Menus' thing.
Many thanks in advance to anyone who can help!