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. How can i get text from CRichEditCtrl

How can i get text from CRichEditCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 2 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.
  • Y Offline
    Y Offline
    york528
    wrote on last edited by
    #1

    it's a chatting tool and i use spy++ get the RichEdit20A handle from the dialog but i can't use the handle to get the text maybe it shields WM_GETTEXT msg how can i get the text in another way??

    C 1 Reply Last reply
    0
    • Y york528

      it's a chatting tool and i use spy++ get the RichEdit20A handle from the dialog but i can't use the handle to get the text maybe it shields WM_GETTEXT msg how can i get the text in another way??

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

      Accessing data of another process isn't that simple...that's one of the main points of protected mode. What do you want to do that involves using spy++ and getting text from a control in another process?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. <

      Y 1 Reply Last reply
      0
      • C Code o mat

        Accessing data of another process isn't that simple...that's one of the main points of protected mode. What do you want to do that involves using spy++ and getting text from a control in another process?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. <

        Y Offline
        Y Offline
        york528
        wrote on last edited by
        #3

        i want to carry out the auto reply function so i have to get the chatting text from the dialog and then analyse it and reply automatically it's hard i know do more and you will learn more ;P thanks for reply

        C 1 Reply Last reply
        0
        • Y york528

          i want to carry out the auto reply function so i have to get the chatting text from the dialog and then analyse it and reply automatically it's hard i know do more and you will learn more ;P thanks for reply

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

          Most IM programs support plugins, maybe it would be easier to write one if the one you want to target there does so? Anyhows, docs say that WM_GETTEXT works over process boundaries for some controls, and for some it doesn't, so i guess for rich edit it doesn't work. You could try a trick but it's not too safe and reliable. You could allocate shared memory, lock it, post WM_GETTEXT to the control passing the address of the shared memory block, wait a while (sadly you can't really know if the rich edit control has processed that message yet or not) and then you should have the text in the memory block. However, this can lead to crashes and asynch problems. You could try for example filling the buffer with 1s, and then after you sent the message keep checking for a 0 character, assuming that you have allocated a big enough buffer, when the 0 is there then the rich edit has probably finished copying its text into the buffer (since 0 should be the last character of the text and we assume it is copying the text from its start to its end). Combining that with maybe some timeouting... Or on a different aproach, you could inject a DLL into the process that hooks itself to the rich edit control and could for example when the control gets WM_SETTEXT copy the text into some shared buffer and notify your process of the change. This all is just ideas, don't know if any of it could ever work.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. <

          Y 1 Reply Last reply
          0
          • C Code o mat

            Most IM programs support plugins, maybe it would be easier to write one if the one you want to target there does so? Anyhows, docs say that WM_GETTEXT works over process boundaries for some controls, and for some it doesn't, so i guess for rich edit it doesn't work. You could try a trick but it's not too safe and reliable. You could allocate shared memory, lock it, post WM_GETTEXT to the control passing the address of the shared memory block, wait a while (sadly you can't really know if the rich edit control has processed that message yet or not) and then you should have the text in the memory block. However, this can lead to crashes and asynch problems. You could try for example filling the buffer with 1s, and then after you sent the message keep checking for a 0 character, assuming that you have allocated a big enough buffer, when the 0 is there then the rich edit has probably finished copying its text into the buffer (since 0 should be the last character of the text and we assume it is copying the text from its start to its end). Combining that with maybe some timeouting... Or on a different aproach, you could inject a DLL into the process that hooks itself to the rich edit control and could for example when the control gets WM_SETTEXT copy the text into some shared buffer and notify your process of the change. This all is just ideas, don't know if any of it could ever work.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. <

            Y Offline
            Y Offline
            york528
            wrote on last edited by
            #5

            Thanks for your advise I'll have a try ;P

            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