Thread: Need help with resource (rc) file

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Unhappy Need help with resource (rc) file

    This is one of my first attempts doing a windows program. I'm trying to include a resource file into my program (Including a window with two buttons), but when I compile, the error "resource.rc (15,9) : Declaration terminated incorrectly" appears.

    I included the file with #include "resource.rc" (I assumed this is how you include resource files, maybe I should do it another way..?)

    I believe that the error has something to do with the resource file, since it has a different syntax than "normal" c/c++ -code. This is how it looks:


    #define DIALOG_2 2
    #define IDC_BUTTON1 101

    DIALOG_2 DIALOG 0, 0, 240, 120
    STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
    CAPTION "Main window"
    FONT 8, "MS Sans Serif"
    {
    CONTROL "OK", IDOK, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 6, 50, 14
    CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 26, 50, 14
    }


    (15,9 is right after DIALOG_2 below the definitions)

    Do you have any idea what is wrong here? I really need help with this...
    I'm using Borland 5.0
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    61
    Ok there are many things that area wrong there

    1. Make a header file called resource.h, take out #define DIALOG_2 2 and #define IDC_BUTTON1 101 and put them in that header file. Then #include that header file in your resource file and in your program.

    2. replace { with BEGIN and } with END in your resource file.

    3. You don't include your resource file with your program you have to compile your resource file into an object file and then link that object file into your project.

  3. #3
    Unregistered
    Guest
    You don't need to use the #include statement in your coding. I use a resource editor that comes with MSVC++ and simply make sure the .rc file is in the project. The compiler will use the .rc file as a reference when creating the project.

    A sample of a resource dialog that I made up using the resource editor follows:

    IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 125
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "Dialog Query"
    FONT 8, "MS Sans Serif"
    BEGIN
    LTEXT "A Simple Modal Dialog Box(with left text)",IDC_STATIC,7,
    33,172,8
    CTEXT "For your viewing pleasure(with centered text)",
    IDC_STATIC,0,47,179,8
    DEFPUSHBUTTON "OK",IDOK,29,73,50,14
    PUSHBUTTON "Cancel",IDCANCEL,108,73,50,14
    END

    This is created with the resource editor from MSVC++ and I don't know too much about Borland's. I hope I have been of some help.

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Reply

    Should I really replace { } with BEGIN / END ? Since the resource code was generated from Borlands resource editor..? (Weird if you must edit it by hand).

    Otherwise, thanks a lot for the reply.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. menu resource file
    By satriani in forum Windows Programming
    Replies: 5
    Last Post: 06-08-2002, 10:52 PM
  5. Resource file/.rc
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 01-26-2002, 07:43 AM