Thread: Resources problem

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    15

    Question Resources problem

    Hello, I have recently started programming in WIN32 API in DEV-C++, where I encountred several problems with resources handling:
    1)whenever I change my resource file, the compiler throws a syntax error:
    {
    [Warning] ISO C requires whitespace after the macro name
    unrecognized escape sequence unrecognized escape sequence

    }


    which, for some paranormal reason can be only fixed by editing the resource header file (PROJECT_NAME.h) in any way(adding whitespace, deleting one, whatever...)

    2) adding MENUITEM in

    Code:
    MAINMENU MENU DISCARDABLE
    BEGIN
              POPUP "FILE" 
           BEGIN
    MENUITEM "The error", IDM_ERROR
           END
    END

    Throws a syntax error



    Does anyone has any idea, where the problem could be?
    Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    That's how I would do it: first create a definitions file ('definitions.h') and declare some values
    Code:
    #define MY_FILE_OPEN   10
    #define MY_FILE_CLOSE 11
    Now create an .*rc resource file and declare the menu inside it
    Code:
    #include <windows.h>
    #include "defintions.h"
    
    menu MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "&Open",MY_FILE_OPEN
            MENUITEM "&Close",MY_FILE_CLOSE
        END
    END
    As you can see the menuitems have an id previously declared in the definitions file. It isn't necessary to declare the definitions (you can do something like 'MENUITEM "&Open",10'), but using definitions will help you to not confusing.

    Now add both files to your project and compile it. There shoudn't be any problem.

    Niara

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    15

    Garland

    Thanks a lot, defining the constants did the job-for now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM