Help with menus?

So, I compile my code, and nothing is wrong in my resource files (.h and .rc). Here they are:
resource.h
1
2
3
4
5
#define IDR_MYMENU 101
#define IDI_MYICON 201

#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002 


resource.rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "resource.h"

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
END

main.cpp
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
#include <windows.h>
#include "resource.h"
#include "resource.rc"

const char g_szClassName[] = "MyWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

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

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

    if(!RegisterClassEx(&wc)){
        MessageBox(NULL, "Window Registration Failed!", "ERROR!",
                   MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,
        "Program Name",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 500, 200,
        NULL, NULL, hInstance, NULL);
    if(hwnd == NULL){
        MessageBox(NULL, "Window Creation Failed!", "ERROR!",
                   MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, NULL, 0, 0) > 0){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
    switch(msg){
            case WM_CREATE:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                char sz_FileName[MAX_PATH];
                GetModuleFileName(hInstance, sz_FileName, MAX_PATH);
                CreateWindow("STATIC",
                             sz_FileName,
                             WS_VISIBLE | WS_CHILD,
                             100, 75, 300, 50,
                             hwnd, NULL, NULL, NULL);
                CreateWindow("STATIC",
                             "Program Location:",
                             WS_VISIBLE | WS_CHILD,
                             175, 20, 125, 25,
                             hwnd, NULL, NULL, NULL);
            }
            break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(NULL);
            break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}


So, as soon as I include these two to my main.cpp file, I get several errors. My g_szClassName seizes to exist, and in WinMain, when I register the window class, at wc.lpszClassName is wrong and says g_szClassName was not declared (line 25), and tehn in my resource.rc it says expected unqualified-id before numeric constant at the IDR_MENU MENU (line 3).

So, sorry about the outrageous length of this, but I really need help. I have been trying to figure out how to use menus and resources for at least 3 months now. I am using Forgers Win32 Digital Book for this, and it isn't working for me. Oh, and I haven't done anything else with the menu yet, I am trying to fix errors. I haven't done the WM_CREATE message for the menu and lpszMenuName yet.
in ressource.rc there is
#include<ressource.h>
and in main.cpp there is
1
2
#include<ressource.h>
#include<ressource.rc> 


so ressource.h is added 2 times which leads to double the
1
2
3
4
5
#define IDR_MYMENU 101
#define IDI_MYICON 201

#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002  

which is wrong
so to avoid these you should add guards to each file:
1
2
3
4
5
#pragma once
#ifndef SOME_UNIQUE_NAME_PER_FILE
#define SOME_UNIQUE_NAME_PER_FILE //the same as above
//the code that should be contained in the file
#endif 

for example ressource.h should be:
1
2
3
4
5
6
7
8
9
#pragma once
#ifndef __RESSOURCE_h
#define __RESSOURCE_h
#define IDR_MYMENU 101
#define IDI_MYICON 201

#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002 
#endif 
Ok, well, instead of doing all that, I just removed the second #defines and #includes. I don't know what #pragma does either, so that is another thing. I narrowed it down to one error: expected unqualified-id before numeric constant. I have no idea how to fix that. It is the place at line 3 in my resource.rc file. Can you help? Did I define it wrong or something?
#pragma once only has a meaning if you use Visual Studio, which is not your case.
Oh, well, thank you, but do you know what is wrong with my resource file? (refer to my last reply)
Topic archived. No new replies allowed.