Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rich Text Edit Issues (several)...

640 views
Skip to first unread message

Steve

unread,
Mar 14, 2007, 4:53:18 PM3/14/07
to
I'm developing a prototype Rich Text Editor window that will
let the users enter rich text and save it to our SQL Server
2005 database.
First I created a new table called RTF_TEST with id_record
(int) as the primary key, and TXT_RTF (text) as the
unlimited column to store the RTF text in the db. I also
created record number 1 (id_record = 1) with a blank TXT_RTF
value.
Next, I created a normal Free-Form datawindow against this
table in PB 10.5.1. However, I noticed that the TXT_RTF
column got typed as char(32766) in the datawindow. I did at
least change the "Limit" to 0 (unlimited), but I don't think
it helped with the issues below.
Next, I placed an RTE control on the window, and coded the
"OPEN" even for the window as follows:
STRING ls_RTF
dw_1.SetTransObject(SQLConn)
dw_1.Retrieve(1)
rte_1.SetRedraw(FALSE)
ls_RTF = dw_1.Object.txt_rtf[1]
rte_1.SelectTextAll()
rte_1.Clear()
rte_1.PasteRTF(ls_RTF)
rte_1.SelectText(0,0,0,0)
rte_1.SetRedraw(TRUE)

Next, the LoseFocus event for the RTE...
STRING ls_RTF
GraphicObject objControl
objControl = GetFocus()
IF (NOT ISVALID(objControl)) THEN
RETURN 0
END IF
IF (TypeOf(objControl) = RichTextEdit!) THEN
RETURN 0
END IF
// Prevent screen flicker...
rte_1.SetRedraw(FALSE)
rte_1.SelectTextAll()
ls_RTF = rte_1.CopyRTF()
dw_1.Object.txt_rtf[1] = ls_RTF
rte_1.SelectText(0,0,0,0)
rte_1.SetRedraw(TRUE)

And finally, I created a Save button with the following
code:
dw_1.Update()

What happens is as follows:
1. At first, I tried to open a word document with a picture
in it and hit Control-A to select the entire word document,
then pasted it into the RTE. Everything pasted just fine
except the image. Only got a skeleton box instead. The users
are really going to want this Copy/Paste to work with the
graphics.
2. Upon right-clicking the RTE and selecting "Insert File",
I was able to open that very same document, and it DID
display the picture properly. I was able to click save, and
it seems to have saved it properly to the database. I ran an
SQL statement to look at the DATALENGTH(txt_rtf), and it
reported 476312 bytes, so I think the entire thing did save
to SQL Server. However, when I open up the window again to
try and re-load the document from SQL Server, it just does
not display anything. No error message either.
3. The statements above that read rte_1.SelectText(0,0,0,0)
do not seem to be working, as the entire document remains
selected even after the script runs.
4. I've turned on the toolbar, but I don't see any Font
Color Picker in the toolbar at the top.
Any help would be much appreciated. I'm excited about this
new RTE control, but want to make sure I'm taking the right
approach to doing this.
Thanks!
=Steve=

Steve

unread,
Mar 14, 2007, 5:03:52 PM3/14/07
to
OK, a little more investigation reveals more info.
I went ahead and put some error checking into the OPEN event
as follows:
STRING ls_RTF
INT li_Result
dw_1.SetTransObject(SQLConn)
li_Result = dw_1.Retrieve(1)
IF (li_Result < 1) THEN
MessageBox("Error return " + STRING(li_Result) + "
retrieving datawindow row 1.","Hey...",StopSign!)
RETURN
END IF

rte_1.SetRedraw(FALSE)
ls_RTF = dw_1.Object.txt_rtf[1]
rte_1.SelectTextAll()
rte_1.Clear()
rte_1.PasteRTF(ls_RTF)
rte_1.SelectText(0,0,0,0)
rte_1.SetRedraw(TRUE)

The Retrieve() method is returning 1 (no error happening
there). However, when I step through the code in the
debugger and inspect the contents of ls_RTF that is fetched
out of the datawindow, the entire RTF text was not present.
I went ahead and copied it to the clipboard and pasted the
partial RTF text into my UltraEdit editor and saved the
file. Guess what the size of the file is? Sure enough, 32K.
So the issue of PowerBuilder assigning the char(32766) size
for the TXT_RTF column is killing this whole thing, I think.
Any ideas?
=Steve=

Brad Wery[TeamSybase]

unread,
Mar 15, 2007, 9:12:55 AM3/15/07
to
You encountered a limitation with the datawindow. It can only put 32k
worth of data into a single column. Ideally, what we need is a new
column type that could handle an infinite amount of characters.

To get around this you will have to use the SELECTBLOB and UPDATEBLOB
commands to retrieve and save data to your database.

Brad


--

Join the Advanced GUI Development project on CodeXchange
https://advanced-gui-development.codexchange.sybase.com/

Brad Wery[TeamSybase]

unread,
Mar 15, 2007, 11:40:12 AM3/15/07
to
For issue 3, try SelectText(1,1,1,1) instead.
For issue 4, the toolbar works fine with my version of PB. What build
number are you using?

Steve

unread,
Mar 15, 2007, 12:43:47 PM3/15/07
to
Thanks Brad.
The on-line help for the UPDATEBLOB statement indicates that
the column in the database should be a "blob" column. Do you
know if it would be OK to leave my SQL Server column as
"text" (unlimited length text)?
Assuming this solves the issue with saving & reading the
larger documents, does anyone know how to solve the first
problem mentioned below where the Copy/Paste from a Word
document does not get the pictures copied into the RTE
control properly?
Thanks.
=Steve=

Brad Wery[TeamSybase]

unread,
Mar 15, 2007, 1:17:09 PM3/15/07
to
SELECTBLOB and UPDATEBLOB will work with the Text database datatype. We
use it all the time here.

As for your first issue, I can't reproduce it. I selected an image from
a word document, copied it then pasted it into my RTE just fine. But, I
do remember seeing this problem once before (with the InsertDocument
function). The image was resized to display smaller in Word but in
reality it's dimesions were really large. The image your pasting into
the RTE may not be scaling down like it does in word. I bet you would
see differenct results if you inserted a small picture into word (do not
size it), then copy and paste it into your RTE. If this is truly the
case, you will need to open a case with Sybase so they can open a case
with the RTE people.

Brad

Mike Niemann

unread,
Mar 16, 2007, 12:40:24 PM3/16/07
to
Steve,

The simple thing to do would be to edit the source for the datawindow, and
set the column width to 100000... or what works for you.

Brad's suggestion is a better solution, but not without potential challenges
as well.

Regards,
Mike Niemann, PBBrowser Author

<Steve> wrote in message news:45f86338.356...@sybase.com...

Steve

unread,
Mar 16, 2007, 3:34:52 PM3/16/07
to
Thanks, I will give these a try. I was able to copy images
from my browser, so maybe it was just MS Word that was
throwing some curve balls. I will do more testing.
Thanks again!

Steven McKenna

unread,
Mar 17, 2007, 10:18:12 AM3/17/07
to
OK, I finally got to the bottom of the Copy/Paste issue from Microsoft Word
into an RTE edit box not bringing over the pictures:
When I originally created the Word document, I got the pictures into the
document by using my web browser (IE 7.0) and searching Google images for a
picture of Bob Barker (just for fun). What I found out is that if you
right-click a picture in your browser and select Copy, then Paste it into a
Word document, it not only embeds the picture into your word document, but
also embeds a hidden link to the web page where you got the picture from on
the Internet. Later on, the readers of your Word document, and hold down the
Control key while they click on the picutre, and it will bring up their
browser and take them to the original site. This extra link information is
confusing the PowerBuilder RTE control, and it doesn't properly paste the
picture while pasting the entire document into the RTE control. To further
prove this, I searched for the very same image in Google, and used my
"PrintKey" screen capture program to copy the picture to the clipboard, and
then pasted that into the Word document. After that, the entire document
Copy/Paste into the RTE control works like a charm!

=Steve=

"Brad Wery[TeamSybase]" <bradweryatagricoreunited.com> wrote in message
news:45f97f95$1@forums-1-dub...

0 new messages