Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can you add a new string resource at runtime?

Can you add a new string resource at runtime?

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    negativeG
    wrote on last edited by
    #1

    Is it possible to add a new string resource at runtime? e.g. I would like to add "My Custom string" with the resource ID "IDR_CUSTOM_STRING" (with some unused value) to the string table. We wish to allow our customers to customize the application. e.g. where it by default says 'Some Program' and 'Some file type (*.som)', they might use 'Bob's Program' and 'Bob's files (*.bob)'. That info in particular is all encoded into the IDR_MYPROGTYPE resource in the string table. The constructor for CMultiDocTemplate only uses this resource to set those strings as needed. I could define a new entry in the string table, and use that, but that works for only a single customization. To allow complete flexibility, I want want to generate a new string table entry based on some data file that is accessed before the DocTemplate is created (early in CMyWinApp). As the resources themselves as part of the exe seems frought with problems, so I am happy to leave that alone. It just seems that at some point that data must be loaded and allocated somewhere, somehow. I just want to add a new one. Or... if there is a safe way to do it, just modify the existing one. Thanks, -G

    A C 2 Replies Last reply
    0
    • N negativeG

      Is it possible to add a new string resource at runtime? e.g. I would like to add "My Custom string" with the resource ID "IDR_CUSTOM_STRING" (with some unused value) to the string table. We wish to allow our customers to customize the application. e.g. where it by default says 'Some Program' and 'Some file type (*.som)', they might use 'Bob's Program' and 'Bob's files (*.bob)'. That info in particular is all encoded into the IDR_MYPROGTYPE resource in the string table. The constructor for CMultiDocTemplate only uses this resource to set those strings as needed. I could define a new entry in the string table, and use that, but that works for only a single customization. To allow complete flexibility, I want want to generate a new string table entry based on some data file that is accessed before the DocTemplate is created (early in CMyWinApp). As the resources themselves as part of the exe seems frought with problems, so I am happy to leave that alone. It just seems that at some point that data must be loaded and allocated somewhere, somehow. I just want to add a new one. Or... if there is a safe way to do it, just modify the existing one. Thanks, -G

      A Offline
      A Offline
      asrelu
      wrote on last edited by
      #2

      Look at BeginUpdateResource.

      1 Reply Last reply
      0
      • N negativeG

        Is it possible to add a new string resource at runtime? e.g. I would like to add "My Custom string" with the resource ID "IDR_CUSTOM_STRING" (with some unused value) to the string table. We wish to allow our customers to customize the application. e.g. where it by default says 'Some Program' and 'Some file type (*.som)', they might use 'Bob's Program' and 'Bob's files (*.bob)'. That info in particular is all encoded into the IDR_MYPROGTYPE resource in the string table. The constructor for CMultiDocTemplate only uses this resource to set those strings as needed. I could define a new entry in the string table, and use that, but that works for only a single customization. To allow complete flexibility, I want want to generate a new string table entry based on some data file that is accessed before the DocTemplate is created (early in CMyWinApp). As the resources themselves as part of the exe seems frought with problems, so I am happy to leave that alone. It just seems that at some point that data must be loaded and allocated somewhere, somehow. I just want to add a new one. Or... if there is a safe way to do it, just modify the existing one. Thanks, -G

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        How about this[^]?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        N 1 Reply Last reply
        0
        • C Code o mat

          How about this[^]?

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          N Offline
          N Offline
          negativeG
          wrote on last edited by
          #4

          I had seen ::UpdateResource() before but it operates on a file, not from with the same program. Oh, well. If I have to make a utility app to do it externally, so be it. At least now I have a template function to do the mechanics of changing the string without having to think about it too much. Thanks for you help -G

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups