views:

29

answers:

2

I have a resource:

IDC_MYMENU MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit"
    END
    POPUP "&Stuff"
    BEGIN
        MENUITEM "&Go"
    END
END

On the first END it says there is a syntax error, I don't understand why. Anyone know? :(

+2  A: 

The problem is that you haven't set the ID for the MENUITEM. The resource compiler expects additional parameter after the string. See documentation here: http://msdn.microsoft.com/en-us/library/aa381025%28VS.85%29.aspx

ybungalobill
+1  A: 

You need an ID associated with a menu item, something like:

#include "resources.h"
#include "windows.h"

IDC_MYMENU MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit", ID_EXIT
    END
    POPUP "&Stuff"
    BEGIN
        MENUITEM "&Go", ID_GO
    END
END

where resources.h would look something like:

#define ID_GO 101

[At east if memory serves, ID_EXIT will normally be pre-defined by Windows.h, so you don't need to define it.]

The ID is the value that your program will receive in the WM_COMMAND message when that menu item is selected. The values are (virtually always) in a separate header for you to include in both the RC file and your code to ensure against any mismatches.

Jerry Coffin