From: David Ching on
"AliR" <AliR(a)online.nospam> wrote in message
news:eMqkFt$fKHA.2596(a)TK2MSFTNGP04.phx.gbl...
> What I'm trying to do is change a bunch of all upper case text into lower
> case. Now I have to either look for a utility or see if I can do it
> myself without losing the RTF formating.
>

Isn't this easy to do with the rich edit control API's?

-- David


From: AliR on
Well I wrote this, seems to be working pretty good. Considering that
everything in target data is english.

int Length = Control.GetTextLength();
BOOL SkipNext = TRUE;
//start from second char
for (int i = 0; i < Length;++i)
{
CString Temp;
if (Control.GetTextRange(i,i+1,Temp) == 1)
{
TCHAR Ch = Temp.GetAt(0);
if (ispunct(Ch))
{
SkipNext = TRUE;
}
else if (isalnum(Ch))
{
if (SkipNext)
{
SkipNext = FALSE;
continue;
}
Control.SetSel(i,i+1);
Temp.MakeLower();
Control.ReplaceSel(Temp);
}
}
}

"AliR" <AliR(a)online.nospam> wrote in message
news:eMqkFt$fKHA.2596(a)TK2MSFTNGP04.phx.gbl...
> Hi Joe,
>
> Thanks for the suggestion.
>
> I did abandon word because of the noise (It almost doubled the size of my
> 1-2 line RTF texts). It also added an extra line at the end of the text
> which I can't live with.
>
> WordPad doesn't have "case change". And I didn't know wordpad had a COM
> interface.
>
> What I'm trying to do is change a bunch of all upper case text into lower
> case. Now I have to either look for a utility or see if I can do it
> myself without losing the RTF formating.
>
> AliR.
>
> "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
> news:njvli51sgh9jdot6fn46tdc3sj3o21lbt3(a)4ax.com...
>> Word would be a Really Bad Idea. Use WordPad, which will not add
>> gratuitous noise to the
>> output file.
>> joe
>>
>> On Thu, 17 Dec 2009 14:47:12 -0600, "AliR" <AliR(a)online.nospam> wrote:
>>
>>>I've been searching up and down for this and haven't found any info yet.
>>>
>>>I have some RTF text that is in a CRichEditCtrl. I want to stick it in
>>>MSWord so I can use CRange::put_Case on it.
>>>
>>>But I can't figure out how to get the text in word! Or more specifically
>>>how
>>>to create a new document, and I'm guess I will have to paste it in.
>>>
>>>AliR.
>>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>
>


From: David Ching on
"AliR" <AliR(a)online.nospam> wrote in message
news:#TgKJ8$fKHA.1648(a)TK2MSFTNGP05.phx.gbl...
> Well I wrote this, seems to be working pretty good. Considering that
> everything in target data is english.
>
> int Length = Control.GetTextLength();
> BOOL SkipNext = TRUE;
> //start from second char
> for (int i = 0; i < Length;++i)
> {
> CString Temp;
> if (Control.GetTextRange(i,i+1,Temp) == 1)
> {
> TCHAR Ch = Temp.GetAt(0);
> if (ispunct(Ch))
> {
> SkipNext = TRUE;
> }
> else if (isalnum(Ch))
> {
> if (SkipNext)
> {
> SkipNext = FALSE;
> continue;
> }
> Control.SetSel(i,i+1);
> Temp.MakeLower();
> Control.ReplaceSel(Temp);
> }
> }
> }
>

SkipNext is set but never used.

Why do you work on only one char at a time? Why don't you get the entire
text into the Temp string, call Temp.MakeLower() once, and replace the
selection at once?

-- David


From: AliR on
I don't do it on the entire text, because I don't want to lose the
formating. Either way I have to look at it one char at a time, since the
first letter of each sentence has to remain upper case.

This code only runs on text where the entire thing is uppercase. Before
running this code there is a test that checks for at least one alpha char
and then if that is true, it calls GetWindowText, and compares the original
text with a MakeUpper version of the string to see if they are the same, if
the are the same then it runs the code.

SkipNext is begin used.

If it is a punctuation then SkipNext is set to TRUE, and when alphanumeric,
then if SkipNext is set to TRUE, it set it to FALSE and goes for the next
character.

AliR.


"David Ching" <dc(a)remove-this.dcsoft.com> wrote in message
news:u9kllNAgKHA.1652(a)TK2MSFTNGP05.phx.gbl...
> "AliR" <AliR(a)online.nospam> wrote in message
> news:#TgKJ8$fKHA.1648(a)TK2MSFTNGP05.phx.gbl...
>> Well I wrote this, seems to be working pretty good. Considering that
>> everything in target data is english.
>>
>> int Length = Control.GetTextLength();
>> BOOL SkipNext = TRUE;
>> //start from second char
>> for (int i = 0; i < Length;++i)
>> {
>> CString Temp;
>> if (Control.GetTextRange(i,i+1,Temp) == 1)
>> {
>> TCHAR Ch = Temp.GetAt(0);
>> if (ispunct(Ch))
>> {
>> SkipNext = TRUE;
>> }
>> else if (isalnum(Ch))
>> {
>> if (SkipNext)
>> {
>> SkipNext = FALSE;
>> continue;
>> }
>> Control.SetSel(i,i+1);
>> Temp.MakeLower();
>> Control.ReplaceSel(Temp);
>> }
>> }
>> }
>>
>
> SkipNext is set but never used.
>
> Why do you work on only one char at a time? Why don't you get the entire
> text into the Temp string, call Temp.MakeLower() once, and replace the
> selection at once?
>
> -- David
>
>


From: David Ching on
"AliR" <AliR(a)online.nospam> wrote in message
news:#$eFgSAgKHA.2104(a)TK2MSFTNGP05.phx.gbl...
> I don't do it on the entire text, because I don't want to lose the
> formating. Either way I have to look at it one char at a time, since the
> first letter of each sentence has to remain upper case.
>
> This code only runs on text where the entire thing is uppercase. Before
> running this code there is a test that checks for at least one alpha char
> and then if that is true, it calls GetWindowText, and compares the
> original text with a MakeUpper version of the string to see if they are
> the same, if the are the same then it runs the code.
>

Oh, OK. I didn't think you'd lose any formatting if you SetSel() an entire
string, but on second thought, you probably would.


> SkipNext is begin used.
>
> If it is a punctuation then SkipNext is set to TRUE, and when
> alphanumeric, then if SkipNext is set to TRUE, it set it to FALSE and goes
> for the next character.
>

Yup, missed it the first time. :-O

Thanks,
David