• Welcome to Valhalla Legends Archive.
 

[Win32] Copying highlighted text from rich edit control and save to string

Started by Okee, July 26, 2005, 09:36 PM

Previous topic - Next topic

Okee

Hey guys, I'm trying to copy the highlighted text from a rich edit control and save it into a string so I can eventually spit it back out later. I've been looking into EM_EXGETSEL, but I don't see where it explains how to use that to actually copy the text into a string. Seems like all it does is copy information about the selection.

My question is how do I go about saving the highlighted text so I can print it out later? I want to copy it into a character array.

Thanks in advance.

MyndFyre

Are you only trying to copy the text itself, not the formatted text?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Okee

Strictly the text. I'm going to append the text to the end of a text file. No formatting required as far as I assumed.

MyndFyre

Seems like EM_GETSELTEXT might be the message for you.

Example:


CHARRANGE range;
SendMessage(hRtfBox, EM_EXGETSEL, NULL, &range);
LONG length = range.cpMax - range.cpMin;
char *buffer = new char[length + 1];
if (!buffer)
  return 0;
lResult = SendMessage(hRtfBox, EM_GETSELTEXT, NULL, (LPARAM)buffer);
if (lResult != length)
  return lResult;

// here is where you do whatever it is you're going to do.  text is in the buffer variable.

delete[] buffer;


Cheers.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.