Scrollbar and RTF

This is my goal:

Insert a rtf document in a text box and use the scrollbar to navigate to the bottom of the document.  When I inserted the contents of the rft into the richtextbox I get jibberish such as /tab/format/printrange/   filling up the entire richtextbox.

so I changed to OLE.  My question is:

A: Can I do this without OLE. and if so I need to know how to take a 15 page RTF document and add it to the Richtextbox (or other control) and scroll up and down it.
(I still don't know how to use the scroll bar, I need code)

B: if I must use OLE, How do I set the scrollbar so It moves the document?

If I am unclear, post a msg I will clarify.
Thanks
 
DAVIDHAsked:
Who is Participating?
 
mark2150Commented:
You can set a file as the properties of the RTF box. You should also set the right margin property to somthing under the width of the RTF box. This will enable word wrap and keep your document looking nice.

Load the "static" text into the RTF box at design time. This will be carried with the box and will apear no matter if the remote file is accessable or not.

Here is a code snippet that will clear the box and load a file if it is available. The RTF box is called NOTES in this example

notes.Text = ""
notes.TextRTF = ""
'
RTFFile = homedrive + "\" + filename + ".rtf"
On Error GoTo nofile
FileLen (RTFFile)               'Traps out if file doesn't exist
notes.LoadFile RTFFile, rtfRTF  'Get file contents
GoTo drain                      'Skip trap
' =================
'
' Here if file doesn't exist - skip load
'
nofile:
Resume drain
' = = = = = = = = = No real fallthru
'
drain:
On Error GoTo 0                 'Turn off trapping
notes.RightMargin = notes.Width 'Non zero margin required for .selAlignment to work!

If you want to *PRINT* your document try:

Private Sub btn_print_Click()
If Not armprinter Then GoTo drain
'
' Select all text and then apply margins to it prior to printing.
'
notes.SelStart = 0
notes.SelLength = Len(notes.Text)
notes.Visible = False
notes.SelIndent = Int(0.75 * TpI + 0.5)
notes.SelRightIndent = Int(0.75 * TpI + 0.5)
'
Printer.Print ""    'This is required to initialize the .hDC needed in next line
notes.SelPrint (Printer.hDC)
On Error Resume Next    'Ignore error if Adobe
Printer.EndDoc
On Error GoTo 0
'
notes.SelIndent = 0
notes.SelRightIndent = 0
notes.SelLength = 0
notes.Visible = True
'
drain:
'
End Sub

the ARMPRINTER function is:

Public Function armprinter() As Boolean
'
' This function is used to determine if printing is required
' The big savings is that any form can call us and that
' particular form doesn't need a COMMONDIALOG object locally
' to determine if printing is switched on. This function returns
' a logical:
'
'   TRUE - Print
'   FALSE - Cancel
'
' Thus the caller can simply use:
'
'   if not armprinter then goto {abort label}
'
' Pretty slick, eh?
'
armprinter = True
On Error GoTo trapped
CommonDialog1.Flags = 0
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
'
' We make it here then user said OK to print, pass default
' value back
'
GoTo drain
' =================
'
' Here on error trap of [Cancel], pass falsity back
'
trapped:
armprinter = False
Resume drain
' = = = = = = No fallthru
'
drain:
End Function

I have a complete form that loads, saves, and allows editing of RTF objects. With it you can change the font, color, alignment, as well as being able to set bold/italic/underline.

Drop me a line at mark_lambert@ntsc.navy.mil if you want the code.

0
 
cantrellCommented:
Read your information in and put the text into the rtf window. Make sure you:

Put the text into the window with rtfWindow.text (without that you will get the rtf jibberish).

Set the property on the rtf box's "DisableNoScroll" to "False" - That should give you the scroll bar if the text is longer than the window.
0
 
DAVIDHAuthor Commented:
Thank you for your help, but I need some detail:

1st:  what is RTFwindow.text?

2nd:  I have never used the scroll bar.  I will need horizontal and vertical.  How do I tie the scroll bars to the RTF conrol?

Here is the code I am using to put the document into the textbox:

Open ("c:\windows\desktop\apps.rtf") For Binary Access Read As #1
RTF1.Text = Input(LOF(1), 1)
Close #1


Thanks!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
cantrellCommented:
Change your line RTF1.Text to RTF1.TextRTF and change the property "Scrollbars" on your RTFbox to "both"
0
 
DAVIDHAuthor Commented:
Your Answer is correct, but It doesn't solve my problem.  I need the contents of the text file to be perminently in the text box.  If the this program is on a different computer, but the file is not, the box should still show the information.  Do I need to use OLE for this?  If so how do I use a scroll bar for this?

Also, when I used the RTF control it works except even though i put both for the scroll bars, it only shows verticle and distorts the data since the document is wider than the box.

If I can solve these problems, I will award the points.

thanks
0
 
cantrellCommented:
I'm a little confused. If the program is on a different computer, but the file is not, you can't open it, unless it's on a networked computer that you have access to.


0
 
DAVIDHAuthor Commented:
Thank you,

My email is Dhill10358@aol.com.  Please send me the source code you mentioned.  I would be most appreciative!

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.