Sign in to follow this  
Defrag

Windows dialogue in visual studio causing errors

Recommended Posts

Defrag    175
I've got a simple menu written by hand and it works fine. However, I now need to create a dialogue with IP address controls and as such I need to use Visual studio 2003's resource editor. However, the moment I edit & save my .rc file using VS, it causes errors. I'm talking about literally just opening the working file, saving it using the resource editor, then compiling (I'm not even trying to add my new dialogue, merely ensure that the original menu will compile properly). Original code:
#include "CLIENT_RES.H"
MainMenu MENU DISCARDABLE
{
	POPUP "&File"
	{
		MENUITEM "E&xit",  MENU_FILE_ID_EXIT
	}

	POPUP "&Connect"
	{
		MENUITEM "Connect",	MENU_CONNECT
		MENUITEM "Disconnect", MENU_DISCONNECT
	}
	
	POPUP "&Help"
	{
		MENUITEM "About",  MENU_HELP_ABOUT
	}

}


Here's what VS generates when I re-save it:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "client_res.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

MAINMENU MENU 
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit",                       MENU_FILE_ID_EXIT
    END
    POPUP "&Connect"
    BEGIN
        MENUITEM "Connect",                     MENU_CONNECT
        MENUITEM "Disconnect",                  MENU_DISCONNECT
    END
    POPUP "&Help"
    BEGIN
        MENUITEM "About",                       MENU_HELP_ABOUT
    END
END


#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""client_res.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

#endif    // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED




Here's the list of errors it generates when attempting to compile:
Compiling resources...
.\client_res.rc(20) : error RC2144 : PRIMARY LANGUAGE ID not a number
.\client_res.rc(29) : error RC2135 : file not found: MAINMENU
.\client_res.rc(31) : error RC2135 : file not found: POPUP
.\client_res.rc(33) : error RC2135 : file not found: MENUITEM
.\client_res.rc(34) : error RC2135 : file not found: END
.\client_res.rc(37) : error RC2164 : unexpected value in RCDATA
.\client_res.rc(38) : error RC2135 : file not found: MENUITEM
.\client_res.rc(39) : error RC2135 : file not found: END
.\client_res.rc(42) : error RC2164 : unexpected value in RCDATA
.\client_res.rc(43) : error RC2135 : file not found: END

...
Client - 10 error(s), 0 warning(s)



I also tried remaking the menu from scratch using the resource editor, but the same thing happens. I've googled various error codes and checked MSDN to no avail; I don't understand what's going on. Any idea what the hell is going on and, more to the point, does anyone know why the resource editor adds so much redundant rubbish to my files? :( Any help much appreciated.

Share this post


Link to post
Share on other sites
yadango    567
yeah, the resource editor always adds a ton of rubbish, mainly for language support, which isn't needed unless you're on an english machine programming an app meant for some other language. it even adds more rubbish for an MFC app. i think there's a missing #endif in that code you posted though.... i really don't use the if !defined preprocessor syntax, but i think it requires and #endif, which i don't see one for it.

what i typically do if i have to use the resource editor is i save a copy of my handmade RC file. i then load the copy into the resource editor and add my dialogs and controls to it. then i open the copy in notepad and copy and paste the DIALOGEX resource into my original. there will be some missing identifiers... i just add these manually to my own resource header (in your case CLIENT_RES.H). i also clean up any syntax or spacing i don't like (like replacing BEGIN and END with {} and so on).

Share this post


Link to post
Share on other sites
Defrag    175
I ended up giving up and just rebuilding it using the resource editor. It must not like trying to build off an existing .rc file of a different format.

Share this post


Link to post
Share on other sites

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