Resources and enum
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Resources and enum

  1. #1
    Join Date
    Jul 2012
    Posts
    24

    Resources and enum

    Hi, I got a problem with a resource file. In my *.rc file I've defined a menu:

    Code:
    #include "resources.h"
    #include "afxres.h"
    
    MAINMENU MENU DISCARDABLE
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "&New",            IDM_FILE_NEW
            MENUITEM "E&xit",             IDM_FILE_EXIT
        END
    /*    POPUP "&Window"
            MENUITEM "&Close All",      IDM_WINDOW_CLALL
        END
        POPUP "&Help"
        BEGIN
            MENUITEM "&Help",           IDM_HELP_HELP
            MENUITEM "&About OurCANOE", IDM_HELP_ABOUT
        END*/
    END
    and in my resource.h file I have the definitions of the IDM identifiers...

    Code:
    #define IDM_FILE_NEW        10000
    #define IDM_FILE_EXIT       10001
    //enum{IDM_FILE_NEW = 10000, IDM_FILE_EXIT};
    //enum {IDM_WINDOW_CLALL = 20000};
    //enum {IDM_HELP_HELP = 30000, IDM_HELP_ABOUT};
    I wanted to use the enum type, to define these identifiers, so I the numbers are assigned automatically, but the compiler throws an error. Is it even possible to use the enum type instead of #define? If not, why? :-)

    Thanks in advance.
    Last edited by HellMaster22; September 20th, 2012 at 02:03 PM.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: Resources and enum

    This is why: Resource compiler is not C++ compiler, it knows nothing about enums.
    Best regards,
    Igor

  3. #3
    Join Date
    Jul 2012
    Posts
    24

    Re: Resources and enum

    Ahhh, thanks. So there is no other choice then to use the preprocessor directive #define. Is there a way, how to use the enum? Because it would simplify the whole ID management... :-)
    Last edited by HellMaster22; September 20th, 2012 at 02:23 PM.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: Resources and enum

    No, there's no a way. RC needs integer ids. Period.
    Best regards,
    Igor

  5. #5
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,027

    Re: Resources and enum

    Completing a little bit beyond the Igor's "period" , the "resource IDs management" can be done by changing _APS_NEXT_RESOURCE_VALUE, _APS_NEXT_COMMAND_VALUE, _APS_NEXT_CONTROL_VALUE, and _APS_NEXT_SYMED_VALUE, which can be found at the bottom of the resource.h file.
    You can find info about them here: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center