RichText control on crack? 
Author Message
 RichText control on crack?

This is a very stange problem that has been driving me nuts and as
best I can tell, I've pinpointed the problem to the RichText control...
I have a RichText control on a form that the user can enter data in
(they can change fonts, colors, etc too). The program saves what they
typed to a database and later can retrieve it for editting. I use this
in several places with no problem. Actually, it seems I only have a
problem with certain text. Here is what happens:

  The user (me in this case :) ) types in some data, then the program
reads the TextRTF property and writes that to a database. So far so
good. Then I read the data from the database. The information read from
the database is:

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
{\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue128;}
\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf1
na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf2
nana\plain\f2\fs17\cf2 n\plain\f2\fs17 ananana
\par }

  Alright, if I step through the code I can see that this is in fact the
data read from the database and stored in a string. Next it assigns the
textRTF property of the RichText control equal to the string it just
read. So, I read the textRTF property, saved *exactly* what I got from
it. And then stored it back into the textRTF property. If I check the
value of the textRTF property right afterwards I get the value:

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
{\colortbl\red0\green0\blue0;\red0\green128\blue128;\red128\green0\blue0;}
\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf2
na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf1
nana\plain\f2\fs17\cf1 n\plain\f2\fs17 ananana
\par }

  Which is *almost* identical. Buy why isn't it identical????? This is
really messing up my code because it checks to see if they changed
anything by seeing the textRTF property matches the data I wrote to it.
It looks like the RichText control is mangling my data. Now, what makes
things stranger is that it doesn't always do it. Sometimes it doesn't
mangle it...but I step through the code and nothing different is
happing.
  I'm running out of hair to pull out! :) Has anyone had similar
experiences? Please, I need my sanity reaffirmed!

  Thanks,

  Kelly Yancey



Sun, 04 Mar 2001 03:00:00 GMT  
 RichText control on crack?
Kelly,

I've no answer to the substance of your query I'm afraid.  As a work around
could you not use the value of the textRTF property of the RTB once you have
loaded the text into it as a check for changes?

Just a thought.

Peter



Mon, 05 Mar 2001 03:00:00 GMT  
 RichText control on crack?
Hi

 I had exactly the same problem here when I needed to do what you're doing.

 To get around it, I resorted to the WinAPI which turned out to be a lot
quicker and less memory intensive than checking the actual text of the
control.

Basically, all edit controls in Windows store a Modified flag which can be
set/get(got?) by the user. When I populate my RTF control, I read the text
from the database then set the Modified flag to False. The user can then
type text into the RTF control which will automatically set the Modified
flag to true.

Here's some code stripped from a Utility ActiveX DLL

Public Function GetDirtyBit(ByVal lHwnd As Long) As Boolean
'
' Returns TRUE / FALSE depending on whether the text of window lHWND has
' been changed since the DirtyBit was set to FALSE
'
    On Error GoTo vbErrorHandler

    GetDirtyBit = SendMessage(lHwnd, EM_GETMODIFY, ByVal 0&, ByVal 0&)
    Exit Function

vbErrorHandler:
' Do error handling
End Function

Public Function LetDirtyBit(ByVal lHwnd As Long, ByVal bDBit As Boolean)
'
' Set the dirty bit of this window handle
'
    On Error GoTo vbErrorHandler

    SendMessage lHwnd, EM_SETMODIFY, ByVal -(CLng(bDBit)), ByVal 0&
    Exit Function

vbErrorHandler:
    '  Do Error Handling
End Function

In this case :

1. Set RTFText Of Your RTF control
2. Call  DirtyBit RTF.hwnd, true
3. Continue .....

4. When you need to check for changes
    if DirtyBit Rtf.hwnd Then ' it's changed !

Hope that helps

Chris Eastwood
Software Engineer
ACNielsen Ltd

Quote:

>This is a very stange problem that has been driving me nuts and as
>best I can tell, I've pinpointed the problem to the RichText control...
>I have a RichText control on a form that the user can enter data in
>(they can change fonts, colors, etc too). The program saves what they
>typed to a database and later can retrieve it for editting. I use this
>in several places with no problem. Actually, it seems I only have a
>problem with certain text. Here is what happens:

>  The user (me in this case :) ) types in some data, then the program
>reads the TextRTF property and writes that to a database. So far so
>good. Then I read the data from the database. The information read from
>the database is:

>{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
>Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
>{\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue128;}
>\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf1
>na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf2
>nana\plain\f2\fs17\cf2 n\plain\f2\fs17 ananana
>\par }

>  Alright, if I step through the code I can see that this is in fact the
>data read from the database and stored in a string. Next it assigns the
>textRTF property of the RichText control equal to the string it just
>read. So, I read the textRTF property, saved *exactly* what I got from
>it. And then stored it back into the textRTF property. If I check the
>value of the textRTF property right afterwards I get the value:

>{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
>Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
>{\colortbl\red0\green0\blue0;\red0\green128\blue128;\red128\green0\blue0;}
>\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf2
>na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf1
>nana\plain\f2\fs17\cf1 n\plain\f2\fs17 ananana
>\par }

>  Which is *almost* identical. Buy why isn't it identical????? This is
>really messing up my code because it checks to see if they changed
>anything by seeing the textRTF property matches the data I wrote to it.
>It looks like the RichText control is mangling my data. Now, what makes
>things stranger is that it doesn't always do it. Sometimes it doesn't
>mangle it...but I step through the code and nothing different is
>happing.
>  I'm running out of hair to pull out! :) Has anyone had similar
>experiences? Please, I need my sanity reaffirmed!

>  Thanks,

>  Kelly Yancey




Mon, 05 Mar 2001 03:00:00 GMT  
 RichText control on crack?
Chris's solution may work for you if you can determine editing during
run-time. The problem materializes because the richtx32 control does not
necessarily treat all formatting as persistant (i.e. what's read back form
what was written may not be interpreted fully). You can even see this
visually with Wordpad by formatting a first line indent; writing a file;
then reloading it. With the code you enclosed in your message, the rtf text
is functionally identical. What was changed was the sequence of color values
in the color table. The 2nd and 3rd values were inverted in the table;
however, the indexing where the colors were used were adjusted to account
for the revision. Certainly can't compare the rtf stream against a file
copy.
Quote:

>This is a very stange problem that has been driving me nuts and as
>best I can tell, I've pinpointed the problem to the RichText control...
>I have a RichText control on a form that the user can enter data in
>(they can change fonts, colors, etc too). The program saves what they
>typed to a database and later can retrieve it for editting. I use this
>in several places with no problem. Actually, it seems I only have a
>problem with certain text. Here is what happens:

>  The user (me in this case :) ) types in some data, then the program
>reads the TextRTF property and writes that to a database. So far so
>good. Then I read the data from the database. The information read from
>the database is:

>{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
>Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
>{\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue128;}
>\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf1
>na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf2
>nana\plain\f2\fs17\cf2 n\plain\f2\fs17 ananana
>\par }

>  Alright, if I step through the code I can see that this is in fact the
>data read from the database and stored in a string. Next it assigns the
>textRTF property of the RichText control equal to the string it just
>read. So, I read the textRTF property, saved *exactly* what I got from
>it. And then stored it back into the textRTF property. If I check the
>value of the textRTF property right afterwards I get the value:

>{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans
>Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
>{\colortbl\red0\green0\blue0;\red0\green128\blue128;\red128\green0\blue0;}
>\deflang1033\pard\plain\f2\fs28 Ban\plain\f2\fs24 a\plain\f2\fs24\cf2
>na\plain\f2\fs24 n\plain\f2\fs20 ana\plain\f2\fs20\cf1
>nana\plain\f2\fs17\cf1 n\plain\f2\fs17 ananana
>\par }

>  Which is *almost* identical. Buy why isn't it identical????? This is
>really messing up my code because it checks to see if they changed
>anything by seeing the textRTF property matches the data I wrote to it.
>It looks like the RichText control is mangling my data. Now, what makes
>things stranger is that it doesn't always do it. Sometimes it doesn't
>mangle it...but I step through the code and nothing different is
>happing.
>  I'm running out of hair to pull out! :) Has anyone had similar
>experiences? Please, I need my sanity reaffirmed!

>  Thanks,

>  Kelly Yancey




Mon, 05 Mar 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. RichText control on crack?

2. Data Control with RichText Control

3. richtext and richtext contol

4. Typing '*' character in Richtext control

5. Access97: RichText control

6. Richtext Control 5.0

7. RichText Control

 

 
Powered by phpBB® Forum Software