Sign in to follow this  

LoadMenu error.

This topic is 3811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was reading the Game Programing Genesis article, and it was great, but I am having trouble leading a menu: my code:
wincl.hIcon = LoadIcon(hThisInstance, "ICON_MAIN");
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = LoadMenu(hThisInstance, MAKEINTRESOURCE(MAIN_MENU));              
wincl.cbClsExtra = 0;                      
wincl.cbWndExtra = 0;
resource file:
MAIN_MENU MENU DISCARDABLE
{
    POPUP "&File"
    {
        MENUITEM "&New",        MENUID_NEW
        MENUITEM "&Open...",    MENUID_OPEN
        MENUITEM "&Save",       MENUID_SAVE
        MENUITEM "Save &As...", MENUID_SAVEAS
        MENUITEM "E&xit",       MENUID_EXIT
    }
    POPUP "&Help"
    {
        MENUITEM "&Contents",   MENUID_CONTENTS
        MENUITEM "&Index...",   MENUID_INDEX
        MENUITEM "&About",      MENUID_ABOUT
    }
}
resource.h :
#define MAIN_MENU		9

#define MENUID_NEW		0
#define MENUID_OPEN		1
#define MENUID_SAVE		2
#define MENUID_SAVEAS	3
#define MENUID_EXIT		4
#define MENUID_CONTENTS	5
#define MENUID_INDEX	6
#define MENUID_ABOUT	7
there error I get is: "cannot convert `HMENU__*' to `const CHAR*' in assignment" it is on this line:
wincl.lpszMenuName = LoadMenu(hThisInstance, MAKEINTRESOURCE(MAIN_MENU));  
thanks in advance (obviously this isnt full source, if you need anything else let me know)

Share this post


Link to post
Share on other sites
The lpsz part of lpszMenuName means that the parameter is a string (Long Pointer String Zero terminated). You dont want an HMENU, you just want a string representing the menu name:

wincl.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU);

Share this post


Link to post
Share on other sites
Thanks a lot, it compiles fine, and after figuring out how to add .rc files to your project in Dev-C++ it works fine :D I also figured out that the gcc MinGW compiler requires you to use BEGIN/END instead of {} in .rc files. Thanks again man ;)

Share this post


Link to post
Share on other sites

This topic is 3811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this