none
MFC resource file refactoring

    Question

  • Hi!

    I was wondering if it is safe to remove all sorts of ID_FILE_OPEN strings and IDs from the application resource (myapp.rc) file.

    I am experimenting with the new MFC FP classes and, since you basically start the project from a wizard generated template, there is a TON of IDs I would like to get rid of.

    What happens if there is a define somewhere in afxres.h, like AFX_IDS_SCSIZE, and you delete the corresponding entry in myapp.rc.

    The technical notes about the topic are extremely long, boring, and seems to dance around the topic without saying anything usefull.
    Wednesday, November 26, 2008 3:40 PM

Answers

  • It's safe to remove anything that you don't actually use in your app.  Just be aware that a default wizard generated app does use the symbols you mentioned, unless you actually go and remove those menu items. 

    The rule of thumb is that if you don't actually get any compiler errors after removing these items, then you should be ok. 
    Thursday, November 27, 2008 3:09 AM

All replies

  • It's safe to remove anything that you don't actually use in your app.  Just be aware that a default wizard generated app does use the symbols you mentioned, unless you actually go and remove those menu items. 

    The rule of thumb is that if you don't actually get any compiler errors after removing these items, then you should be ok. 
    Thursday, November 27, 2008 3:09 AM
  • Thank you!

    But what about things like AFX_IDS_APP_TITLE? It's not referenced in my code, but it looks weirdly suspicious... I am afraid that even though the code will compile, it will break some weird CFrame function deep down the engine, or it will display some junk like "Enter your app title here" somewhere when shipped. Tree view classes display dummy data if you havn't added anything to them!!!

    I don't want to go through all the localization stuff for those unknown IDs as there are quite a few of them, nor I can do that if there is no information about where they are used. For example: ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane", should it read as "Click here to ...." or "Pressing the shortcut will ...". All of this seems like a bloody mess. And if you have a Japanese interface then phrase like "Enter your app title here", or one unique [English (U.S.)] button can totally ruin the whole look and feel of the application.

    And because of macro way the stuff has been written I can't even put a data breakpint on  that thing to find if it's even referenced at all.

    Does anyone know where to look for official docs for this thing?

    I'm totally confused...


    Thursday, November 27, 2008 10:42 AM
  • You're correct, there are some symbols that are used by MFC and they are assumed to be there.  I should not have stated that they are only menu items, that's incorrect.  There's other stuff in MFC that might use them.

    What gets even more messy is that if you have an extension DLL that has some resource strings in it, be sure not to use the same id's as any of those built in ones, as your strings will get picked up by the resource chainer rather than the MFC DLLs.

    There's no documentation as far as I nkow. 
    Monday, December 08, 2008 1:36 PM