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. String table

String table

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • R Offline
    R Offline
    Roger
    wrote on last edited by
    #1

    Is there anyway at runtime to add a string into the string table? What I am trying to do is have a thread load a string to the string table, then use postmessage back to the main thread. Inside of the main thread message handler I want to pop up a warning dialog that will display the string I added to the string table. Is this viable, if not what other approaches could I use?

    E realJSOPR 2 Replies Last reply
    0
    • R Roger

      Is there anyway at runtime to add a string into the string table? What I am trying to do is have a thread load a string to the string table, then use postmessage back to the main thread. Inside of the main thread message handler I want to pop up a warning dialog that will display the string I added to the string table. Is this viable, if not what other approaches could I use?

      E Offline
      E Offline
      Erik Funkenbusch
      wrote on last edited by
      #2

      What you're asking is not viable really. Remember that string resources are embedded in the executable, thus adding a string at runtime, permanently adds the string to the executable (even if it were possible to add one while another executable is running, which is usually not possible because the file image is locked). What you probably want to do is simply send a string to another app and have that app display it. You can do this using the WM_COPYDATA message, which you can then add a WM_COPYDATA handler to your application.

      1 Reply Last reply
      0
      • R Roger

        Is there anyway at runtime to add a string into the string table? What I am trying to do is have a thread load a string to the string table, then use postmessage back to the main thread. Inside of the main thread message handler I want to pop up a warning dialog that will display the string I added to the string table. Is this viable, if not what other approaches could I use?

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        What Eric suggested is the best way, but if the two threads are within the same process, all you need is a user-defined message and to use either the WPARAM or LPARAM to send a pointer to the string. Here's how you do it with a user-defined message the last parameter is LPARAM and is not used in this example) - I also assume you're using a CString, hence the double-cast for the WPARAM: void CMyClass::SendMyMsg(CString sMsg) { SendMessage(UWM_MYMESSAGE,(WPARAM)((LPCSTR)sMsg), 0); } In your message handler, you'd do this: LRESULT CMyDialog::OnMyMsg(WPARAM wParam, LPARAM lParam) { CString sMyRcvdMsg = (LPCTSTR)wParam; // do something with the string now return 1L; } Using WM_COPYDATA is MUCH more flexible however. I'm working on an app right now that uses WM_COPYDATA quite extensively because of the added flexibility. When it's done, I will be posting it here.

        R 1 Reply Last reply
        0
        • realJSOPR realJSOP

          What Eric suggested is the best way, but if the two threads are within the same process, all you need is a user-defined message and to use either the WPARAM or LPARAM to send a pointer to the string. Here's how you do it with a user-defined message the last parameter is LPARAM and is not used in this example) - I also assume you're using a CString, hence the double-cast for the WPARAM: void CMyClass::SendMyMsg(CString sMsg) { SendMessage(UWM_MYMESSAGE,(WPARAM)((LPCSTR)sMsg), 0); } In your message handler, you'd do this: LRESULT CMyDialog::OnMyMsg(WPARAM wParam, LPARAM lParam) { CString sMyRcvdMsg = (LPCTSTR)wParam; // do something with the string now return 1L; } Using WM_COPYDATA is MUCH more flexible however. I'm working on an app right now that uses WM_COPYDATA quite extensively because of the added flexibility. When it's done, I will be posting it here.

          R Offline
          R Offline
          Roger
          wrote on last edited by
          #4

          That is what I ended up doing. I was more curious than anything about posting into the string table, seems like something that would be neat (technical term) to be able to do though. Thanks for the help!

          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