IDR_MYMENU MENU
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
BEGIN
IDI_MYICON ICON "menu_one.ico"
the code in .c
#include "resource.h"
#include "myrc.rc"
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
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_ICONINFORMATION|MB_OK);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,g_szClassName,"The title of my window",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,600,300,NULL,NULL,hInstance,NULL);
while (GetMessage(&Msg,NULL,0,0)>0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
I went ahead to change #define MY_MENU 101 to const int MY_MENU = 101;
then a new error message: redeclaration of const int MY_MENU
which am very sure I initialized once.
I don't know where I've goon wrong, any help would be appreciated.Tnx
You cannot include .rc file in .c (which is of course not a header). You need to add the .rc to your project.
What you have is basically what you get when you create a new win32 project. I've something similar and it works [only] without including the .rc into the .c
IDR_MYMENU MENU
BEGIN // <-- Where's the matching END?
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
BEGIN // <-- Isn't this supposed to be END?